:root {
    --bg: #0b1220;
    --panel: rgba(10, 17, 30, 0.72);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text: #edf6ff;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    overflow: hidden;
}

body {
    position: relative;
}

#game-shell {
    position: relative;
    width: 100vw;
    height: 100vh;
    /* En el móvil, 100vh incluye la zona que tapa la barra del navegador: se usa
       la altura visible real para que la barra inferior del juego no quede oculta. */
    height: 100dvh;
    background: radial-gradient(circle at top, #182a44 0%, var(--bg) 60%);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

#hud {
    position: absolute;
    /* Abajo a la izquierda: arriba quedan los tableros. */
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 14px;
    z-index: 10;
    width: min(350px, calc(100vw - 28px));
}

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    backdrop-filter: blur(8px);
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.35);
}

#hud .panel {
    padding: 12px 14px;
}

#hud h1 {
    margin: 0 0 6px;
    font-size: clamp(1.15rem, 2vw, 1.8rem);
}

#hud p {
    margin: 0;
    font-size: 0.95rem;
    color: rgba(237, 246, 255, 0.9);
}

#hud .turn-info {
    margin-top: 6px;
    font-size: 0.85rem;
    color: rgba(237, 246, 255, 0.7);
}

#hud .turn-info:empty {
    display: none;
}

.actions-panel:empty {
    display: none;
}

.action {
    font: inherit;
    font-size: 0.85rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.action:hover {
    background: rgba(255, 255, 255, 0.16);
}

.actions-panel {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.action.primary {
    background: #2563eb;
    border-color: #3b82f6;
    font-weight: bold;
}

.action.primary:hover {
    background: #1d4ed8;
}

.players-panel {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 8px;
}

.players-panel:empty {
    display: none;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    padding: 3px 6px;
    border-radius: 6px;
}

.player-row.current {
    background: rgba(147, 197, 253, 0.16);
}

.player-row.eliminated {
    opacity: 0.45;
    text-decoration: line-through;
}

.player-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.5);
    flex: none;
}

.player-name {
    font-weight: bold;
}

.player-stats {
    margin-left: auto;
    color: rgba(237, 246, 255, 0.75);
}

.actions-panel {
    flex-wrap: wrap;
}

.action.danger-outline {
    background: transparent;
    border-color: rgba(248, 113, 113, 0.6);
    color: #fca5a5;
}

.action.danger,
.action.danger-outline:hover {
    background: #b91c1c;
    border-color: #ef4444;
    color: #fff;
}

.piece-icon {
    display: inline-block;
    font-size: 1.9rem;
    line-height: 1;
    font-family: "Segoe UI Symbol", "DejaVu Sans", "Noto Sans Symbols 2", serif;
}

.player-row .piece-icon {
    font-size: 1.15rem;
}

/* Ventana de la caja */
.modal {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 10, 20, 0.45);
    padding: 16px;
}

.modal[hidden] {
    display: none;
}

.modal-content {
    background: rgba(10, 17, 30, 0.94);
    width: min(640px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 14px 16px;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-points {
    color: rgba(237, 246, 255, 0.75);
    font-size: 0.9rem;
}

.modal-close {
    margin-left: auto;
    font: inherit;
    color: var(--text);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
}

.modal-note {
    margin: 0 0 8px;
    font-size: 0.85rem;
    color: #fcd34d;
}

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

.box-table th {
    text-align: center;
    font-weight: normal;
    font-size: 0.78rem;
    color: rgba(237, 246, 255, 0.6);
    padding: 4px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.box-table td {
    text-align: center;
    padding: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.box-table .icon-cell {
    width: 44px;
}

.box-table .actions-cell {
    white-space: nowrap;
    text-align: right;
}

.table-action {
    font: inherit;
    font-size: 0.8rem;
    color: var(--text);
    background: rgba(147, 197, 253, 0.15);
    border: 1px solid rgba(147, 197, 253, 0.45);
    border-radius: 7px;
    padding: 5px 8px;
    margin-left: 4px;
    cursor: pointer;
}

.table-action.shop {
    background: rgba(250, 204, 21, 0.12);
    border-color: rgba(250, 204, 21, 0.4);
}

.table-action:hover:not(:disabled) {
    filter: brightness(1.4);
}

.table-action:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Páginas normales (nueva partida) */
body.page {
    overflow: auto;
    background: radial-gradient(circle at top, #182a44 0%, var(--bg) 60%);
    min-height: 100%;
}

.page-main {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.page-card {
    padding: 16px 18px;
    margin-bottom: 16px;
}

.page-card h2 {
    margin: 0 0 8px;
    font-size: 1.15rem;
}

.page-card fieldset {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    margin: 0 0 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.page-card label {
    display: flex;
    gap: 10px;
    align-items: center;
}

.page-card input[type="text"],
.page-card input[type="number"],
.page-card select {
    font: inherit;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 6px 8px;
}

.page-card select option {
    color: #111;
}

.page-card a {
    color: #93c5fd;
}

.page-error {
    color: #fca5a5;
}

.player-links li {
    margin-bottom: 6px;
}

/* Aviso grande de turno / fin de partida */
.turn-banner {
    position: absolute;
    top: 18%;
    left: 50%;
    z-index: 30;
    transform: translate(-50%, -50%);
    padding: 18px 36px;
    border-radius: 18px;
    font-size: clamp(1.6rem, 4vw, 2.8rem);
    font-weight: bold;
    color: #fff;
    background: rgba(37, 99, 235, 0.92);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    white-space: nowrap;
}

.turn-banner[hidden] {
    display: none;
}

.turn-banner.win {
    background: rgba(22, 163, 74, 0.94);
}

.turn-banner.lose {
    background: rgba(185, 28, 28, 0.94);
}

.turn-banner.show {
    animation: banner-in 2.8s ease forwards;
}

@keyframes banner-in {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
    12% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
    20% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* Tiempo del turno */
#hud .turn-timer {
    margin: 6px 0 0;
    font-size: 1.05rem;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    color: rgba(237, 246, 255, 0.85);
}

#hud .turn-timer[hidden] {
    display: none;
}

#hud .turn-timer.mine {
    color: #93c5fd;
}

#hud .turn-timer.urgent {
    color: #f87171;
    animation: timer-pulse 1s ease-in-out infinite;
}

.player-timer {
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: #93c5fd;
}

.player-timer.urgent {
    color: #f87171;
}

@keyframes timer-pulse {
    50% { opacity: 0.55; }
}

/* Botón de sonido */
.sound-toggle {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    right: 14px;
    z-index: 15;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--text);
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    cursor: pointer;
}

.sound-toggle:hover {
    background: rgba(30, 41, 59, 0.9);
}

.sound-toggle.muted {
    opacity: 0.7;
}

/* Aún no se ha activado el audio (el navegador espera un clic). */
.sound-toggle.waiting {
    animation: timer-pulse 1.6s ease-in-out infinite;
}

/* ------------------------------------------------------------------------- */
/* Pantallas pequeñas                                                        */
/* ------------------------------------------------------------------------- */
/* En escritorio solo se ve el panel; la barra y el botón de cerrar, no. */
.mobile-bar,
.hud-collapse {
    display: none;
}

@media (max-width: 700px), (max-height: 520px) {
    /* Barra inferior de lado a lado: turno y tiempo, jugadores y ampliar. */
    .mobile-bar {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 12;
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 52px;
        padding: 6px 60px 6px 10px;
        padding-bottom: max(6px, env(safe-area-inset-bottom));
        padding-left: max(10px, env(safe-area-inset-left));
        background: rgba(10, 17, 30, 0.86);
        border-top: 1px solid var(--panel-border);
        backdrop-filter: blur(8px);
    }

    .bar-turn {
        flex: 0 1 auto;
        min-width: 0;
        font-size: 0.82rem;
        font-weight: bold;
        font-variant-numeric: tabular-nums;
        line-height: 1.2;
        color: rgba(237, 246, 255, 0.85);
        max-width: 38%;
    }

    .bar-turn.mine {
        color: #93c5fd;
    }

    .bar-turn.urgent {
        color: #f87171;
        animation: timer-pulse 1s ease-in-out infinite;
    }

    .bar-players {
        flex: 1 1 auto;
        min-width: 0;
        display: flex;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .bar-players::-webkit-scrollbar {
        display: none;
    }

    .bar-player {
        flex: none;
        display: flex;
        align-items: center;
        gap: 4px;
        padding: 3px 7px;
        border-radius: 8px;
        font-size: 0.78rem;
        white-space: nowrap;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid transparent;
    }

    .bar-player.current {
        background: rgba(147, 197, 253, 0.16);
        border-color: rgba(147, 197, 253, 0.45);
    }

    .bar-player.eliminated {
        opacity: 0.45;
    }

    .bar-player .piece-icon {
        font-size: 1.1rem;
    }

    /* El tiempo ya aparece en el texto del turno. */
    .bar-player .player-timer {
        display: none;
    }

    .bar-expand {
        flex: none;
        width: 40px;
        height: 40px;
        border-radius: 10px;
        font-size: 1rem;
        color: var(--text);
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.18);
        cursor: pointer;
    }

    /* El botón de sonido pasa abajo a la derecha, dentro de la barra. */
    .sound-toggle {
        top: auto;
        bottom: max(6px, env(safe-area-inset-bottom));
        right: max(8px, env(safe-area-inset-right));
        width: 40px;
        height: 40px;
        font-size: 1.15rem;
        backdrop-filter: none;
    }

    /* Panel completo: oculto hasta que se amplía; entonces ocupa casi toda la pantalla. */
    #hud {
        display: none;
    }

    body.hud-expanded #hud {
        display: block;
        top: max(8px, env(safe-area-inset-top));
        left: 8px;
        right: 8px;
        bottom: max(8px, env(safe-area-inset-bottom));
        width: auto;
        z-index: 18;
    }

    body.hud-expanded #hud .panel {
        height: 100%;
        overflow-y: auto;
        padding: 14px 16px;
        background: rgba(10, 17, 30, 0.95);
    }

    body.hud-expanded .mobile-bar {
        display: none;
    }

    body.hud-expanded .sound-toggle {
        display: none;
    }

    .hud-collapse {
        display: block;
        float: right;
        width: 40px;
        height: 40px;
        margin: -4px -6px 6px 10px;
        border-radius: 10px;
        font: inherit;
        font-size: 1.1rem;
        color: var(--text);
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.2);
        cursor: pointer;
    }

    #hud h1 {
        font-size: 1.15rem;
    }

    .action {
        padding: 9px 12px;
    }

    /* Ventana de la caja y avisos adaptados al ancho. */
    .modal {
        padding: 8px;
    }

    .modal-content {
        max-height: calc(100vh - 16px);
        padding: 12px;
    }

    .box-table {
        font-size: 0.8rem;
    }

    .box-table th,
    .box-table td {
        padding: 4px 3px;
    }

    .table-action {
        padding: 7px 8px;
        margin: 2px 0 2px 3px;
    }

    .box-table .actions-cell {
        white-space: normal;
    }

    .turn-banner {
        white-space: normal;
        text-align: center;
        width: max-content;
        max-width: calc(100vw - 32px);
        padding: 14px 22px;
    }
}

/* ------------------------------------------------------------------------- */
/* Repetición de una partida                                                 */
/* ------------------------------------------------------------------------- */
.replay-bar {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 14;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    width: min(560px, calc(100vw - 90px));
}

.replay-button {
    flex: none;
    width: 38px;
    height: 36px;
    font: inherit;
    font-size: 1rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    cursor: pointer;
}

.replay-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.16);
}

.replay-button:disabled {
    opacity: 0.35;
    cursor: default;
}

#replayToggle {
    background: #2563eb;
    border-color: #3b82f6;
}

.replay-slider {
    flex: 1 1 auto;
    min-width: 60px;
    accent-color: #3b82f6;
}

.replay-player {
    flex: none;
    display: flex;
    align-items: center;
    gap: 5px;
    max-width: 130px;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(147, 197, 253, 0.16);
    border: 1px solid rgba(147, 197, 253, 0.45);
}

.replay-player .piece-icon {
    font-size: 1.2rem;
}

.replay-counter {
    flex: none;
    min-width: 54px;
    text-align: right;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: rgba(237, 246, 255, 0.75);
}

@media (max-width: 700px), (max-height: 520px) {
    /* En pantallas pequeñas, justo encima de la barra inferior. */
    .replay-bar {
        top: auto;
        bottom: calc(60px + env(safe-area-inset-bottom));
        left: 8px;
        right: 8px;
        transform: none;
        width: auto;
        gap: 4px;
        padding: 6px 8px;
    }

    .replay-button {
        width: 34px;
    }

    .replay-counter {
        display: none;
    }

    body.hud-expanded .replay-bar {
        display: none;
    }
}

/* ------------------------------------------------------------------------- */
/* Imagen del escenario y modo captura                                       */
/* ------------------------------------------------------------------------- */
.modal-content.modal-wide {
    width: min(960px, 100%);
}

.scenario-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Al hacer la imagen de un escenario solo se ve la escena. */
body.capture-mode #hud,
body.capture-mode .mobile-bar,
body.capture-mode .sound-toggle,
body.capture-mode .turn-banner {
    display: none !important;
}

/* Imagen del escenario en la página de nueva partida. */
.scenario-preview {
    margin-top: 12px;
}

.scenario-preview img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.scenario-preview p {
    margin: 6px 0 0;
    font-size: 0.9rem;
}

/* Botón «Centrar vista», a la izquierda del de sonido. */
.sound-toggle.view-reset {
    right: 66px;
    font-size: 1.4rem;
}

body.capture-mode .view-reset {
    display: none !important;
}

@media (max-width: 700px), (max-height: 520px) {
    .sound-toggle.view-reset {
        right: calc(max(8px, env(safe-area-inset-right)) + 46px);
        font-size: 1.25rem;
    }

    /* Hueco en la barra para los dos botones. */
    .mobile-bar {
        padding-right: 106px;
    }

    body.hud-expanded .view-reset {
        display: none;
    }
}

/* ------------------------------------------------------------------------- */
/* Partida guiada (demo.php)                                                 */
/* ------------------------------------------------------------------------- */
.tutorial {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    left: 14px;
    z-index: 16;
    width: min(440px, calc(100vw - 150px));
    max-height: calc(100vh - 330px);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    background: rgba(10, 17, 30, 0.88);
}

.tutorial[hidden] {
    display: none;
}

.tutorial-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 0;
}

.tutorial-progress {
    flex: none;
    font-size: 0.8rem;
    color: rgba(237, 246, 255, 0.65);
}

.tutorial-jump {
    flex: 1 1 auto;
    min-width: 0;
    font: inherit;
    font-size: 0.82rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 4px 6px;
}

.tutorial-jump option {
    color: #111;
}

.tutorial-toggle {
    flex: none;
    width: 30px;
    height: 30px;
    font: inherit;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
}

.tutorial-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 4px 14px 6px;
}

.tutorial-body h2 {
    margin: 6px 0 8px;
    font-size: 1.2rem;
}

.tutorial-text {
    font-size: 0.9rem;
    line-height: 1.45;
    color: rgba(237, 246, 255, 0.92);
}

.tutorial-text p,
.tutorial-text ul {
    margin: 0 0 8px;
}

.tutorial-text ul {
    padding-left: 20px;
}

.tutorial-text a {
    color: #93c5fd;
}

.tutorial-text a.action {
    display: inline-block;
    color: var(--text);
    text-decoration: none;
}

.tutorial-text kbd {
    display: inline-block;
    min-width: 1.4em;
    padding: 1px 5px;
    font: inherit;
    font-size: 0.8rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.08);
}

.tutorial-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 8px;
    font-size: 0.8rem;
}

.tutorial-table th,
.tutorial-table td {
    padding: 4px 5px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    vertical-align: top;
}

.tutorial-table th {
    font-weight: normal;
    color: rgba(237, 246, 255, 0.6);
}

.hl {
    padding: 0 5px;
    border-radius: 4px;
    color: #0b1220;
    font-weight: bold;
}

.hl-move { background: #93c5fd; }
.hl-capture { background: #fca5a5; }
.hl-teleport { background: #5eead4; }

.tutorial-caption {
    margin: 4px 0 4px;
    padding: 7px 10px;
    font-size: 0.88rem;
    border-radius: 8px;
    background: rgba(250, 204, 21, 0.14);
    border: 1px solid rgba(250, 204, 21, 0.4);
    color: #fde68a;
}

.tutorial-caption[hidden] {
    display: none;
}

.tutorial-nav {
    display: flex;
    gap: 8px;
    padding: 8px 12px 12px;
}

.tutorial-nav .action {
    flex: 1 1 0;
}

.tutorial-nav .action:disabled {
    opacity: 0.35;
    cursor: default;
}

.tutorial.collapsed .tutorial-body {
    display: none;
}

.tutorial.collapsed {
    min-height: 0;
}

@media (max-width: 700px), (max-height: 520px) {
    .tutorial {
        top: max(8px, env(safe-area-inset-top));
        left: 8px;
        right: 8px;
        width: auto;
        min-height: 0;
        max-height: 46vh;
    }

    .tutorial-text {
        font-size: 0.84rem;
    }
}

/* Botón «Inicio» del juego, a la izquierda de «Centrar vista». */
.sound-toggle.home-link {
    right: 118px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1.35rem;
}

body.capture-mode .home-link {
    display: none !important;
}

@media (max-width: 700px), (max-height: 520px) {
    .sound-toggle.home-link {
        right: calc(max(8px, env(safe-area-inset-right)) + 92px);
        font-size: 1.2rem;
    }

    .mobile-bar {
        padding-right: 152px;
    }

    body.hud-expanded .home-link {
        display: none;
    }
}

/* ------------------------------------------------------------------------- */
/* Páginas: cabecera, cuenta, portada, perfiles                              */
/* ------------------------------------------------------------------------- */
.site-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 16px 0;
}

.site-logo {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text);
    text-decoration: none;
}

.site-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.site-nav a {
    color: #93c5fd;
    text-decoration: none;
}

.site-nav a.action {
    color: var(--text);
}

.site-user {
    display: flex;
    align-items: center;
    gap: 6px;
}

.site-user img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.site-user span {
    color: var(--text);
    font-weight: bold;
}

.site-user small {
    color: rgba(237, 246, 255, 0.65);
}

.inline-form {
    display: inline;
    margin: 0;
}

.link-button {
    font: inherit;
    color: #93c5fd;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
}

body.page .page-main {
    max-width: 1100px;
}

.page-main h1 {
    margin: 10px 0 14px;
}

.page-card h1 {
    margin-top: 0;
}

.flash {
    padding: 10px 14px;
    border-radius: 10px;
    margin: 0 0 14px;
}

.flash-ok {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.45);
}

.flash-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #fecaca;
}

.muted {
    color: rgba(237, 246, 255, 0.62);
}

.page-card a {
    color: #93c5fd;
}

.page-card a.action {
    color: var(--text);
    text-decoration: none;
    display: inline-block;
}

.action.big {
    font-size: 1.05rem;
    padding: 12px 20px;
}

.auth-card {
    max-width: 440px;
    margin: 20px auto;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.page-card .form-stack label {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}

.page-card .form-stack label.check {
    flex-direction: row;
    align-items: center;
}

.page-card input[type="email"],
.page-card input[type="password"],
.page-card input[type="search"],
.page-card input[type="file"] {
    font: inherit;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 10px;
}

.form-stack input:not([type="checkbox"]) {
    width: 100%;
    padding: 9px 10px;
}

.hero {
    text-align: center;
    padding: 28px 20px;
}

.hero h1 {
    font-size: 2.2rem;
}

.hero p {
    max-width: 640px;
    margin: 0 auto 14px;
    line-height: 1.5;
}

.hero-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.open-game {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
    border-color: rgba(59, 130, 246, 0.6);
    background: rgba(37, 99, 235, 0.18);
}

.open-game h2,
.open-game p {
    margin: 0 0 4px;
}

.dashboard {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
}

.me-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.me-card h1,
.me-card h2 {
    margin: 0 0 4px;
}

.me-card p {
    margin: 0 0 4px;
}

.avatar-lg {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
    flex: none;
}

.avatar-sm {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
}

.dashboard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.inline-search {
    display: flex;
    gap: 6px;
    margin: 0;
}

.inline-search input {
    min-width: 0;
    width: 200px;
}

.two-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.data-table td,
.data-table th {
    text-align: left;
}

.data-table small {
    color: rgba(237, 246, 255, 0.6);
}

.player-cell {
    white-space: nowrap;
}

.plain-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.invite-box {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: flex-end;
    margin: 12px 0;
}

.invite-box > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.game-code {
    font-size: 2.2rem;
    letter-spacing: 0.12em;
    font-variant-numeric: tabular-nums;
}

.invite-link {
    flex: 1 1 280px;
}

.invite-link input {
    width: 100%;
}

.seat-list {
    list-style: none;
    padding: 0;
    margin: 0 0 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.seat-list li {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.seat-list li.taken {
    background: rgba(34, 197, 94, 0.14);
}

.seat-list li.free {
    color: rgba(237, 246, 255, 0.55);
}

.seat-color {
    min-width: 90px;
    font-weight: bold;
}

.waiting-room .scenario-preview img {
    max-width: 520px;
}

@media (max-width: 600px) {
    .site-nav {
        margin-left: 0;
        width: 100%;
        gap: 10px;
    }

    .inline-search input {
        width: 100%;
    }

    .inline-search {
        width: 100%;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .game-code {
        font-size: 1.8rem;
    }
}

/* ------------------------------------------------------------------------- */
/* Logotipo de MTChess                                                       */
/* ------------------------------------------------------------------------- */
.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.site-logo img {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    flex: none;
}

.site-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.site-logo-name {
    font-size: 1.25rem;
    font-weight: bold;
}

.site-logo-tagline {
    font-size: 0.72rem;
    font-weight: normal;
    letter-spacing: 0.06em;
    color: rgba(237, 246, 255, 0.6);
}

.hero-logo {
    display: block;
    width: 200px;
    height: 200px;
    margin: 0 auto 6px;
    border-radius: 28px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.hero h1 {
    margin-bottom: 2px;
}

.hero-tagline {
    font-size: 1.05rem;
    letter-spacing: 0.08em;
    color: rgba(237, 246, 255, 0.7);
}

.tutorial-logo {
    float: right;
    width: 64px;
    height: 64px;
    margin: 0 0 6px 10px;
    border-radius: 12px;
}

@media (max-width: 600px) {
    .hero-logo {
        width: 150px;
        height: 150px;
    }
}

/* Logotipo transparente: sin fondo ni esquinas, solo una sombra suave. */
.hero-logo-title {
    margin: 0;
    line-height: 0;
}

.hero-logo {
    border-radius: 0;
    box-shadow: none;
    filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.45));
}

.site-logo img,
.tutorial-logo {
    border-radius: 0;
}

/* ------------------------------------------------------------------------- */
/* Iconos de visión y formas de perder (assets/img/icons.svg)                */
/* ------------------------------------------------------------------------- */
.icon {
    width: 20px;
    height: 20px;
    flex: none;
    vertical-align: middle;
}

.icon-lg {
    width: 34px;
    height: 34px;
}

.icon-inline {
    width: 18px;
    height: 18px;
    margin: -2px 2px 0 0;
    color: #93c5fd;
}

/* Panel del juego: una fila de iconos con su explicación al pasar por encima. */
#hud .turn-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rules-icons {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.rule-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: help;
    color: #93c5fd;
    background: rgba(147, 197, 253, 0.12);
    border: 1px solid rgba(147, 197, 253, 0.35);
}

.rule-icon.rule-loss {
    color: #fca5a5;
    background: rgba(252, 165, 165, 0.1);
    border-color: rgba(252, 165, 165, 0.35);
}

.rules-sep {
    margin-left: 6px;
    font-size: 0.75rem;
    color: rgba(237, 246, 255, 0.55);
}

.hud-hint {
    color: rgba(237, 246, 255, 0.85);
}

/* Creación de partida: tarjetas con icono y texto. */
.option-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
}

.page-card label.option-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
}

.option-card input {
    margin-top: 9px;
}

.option-card .icon {
    color: #93c5fd;
}

.option-card span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.option-card small {
    color: rgba(237, 246, 255, 0.65);
    line-height: 1.35;
}

.option-card:has(input:checked) {
    border-color: rgba(59, 130, 246, 0.8);
    background: rgba(37, 99, 235, 0.18);
}

.option-card.fixed {
    cursor: default;
    opacity: 0.85;
}

.loss-cards .option-card .icon,
.option-card.fixed .icon {
    color: #fca5a5;
}

/* Resumen de reglas (sala de espera, unirse a una partida). */
.rules-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 6px 0 14px;
}

.rule-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    color: #bfdbfe;
    background: rgba(147, 197, 253, 0.12);
    border: 1px solid rgba(147, 197, 253, 0.35);
}

.rule-chip.loss {
    color: #fecaca;
    background: rgba(252, 165, 165, 0.1);
    border-color: rgba(252, 165, 165, 0.35);
}

.rule-chip .icon {
    width: 18px;
    height: 18px;
}

/* Enlaces sueltos de las páginas (fuera de las tarjetas): legibles sobre el fondo oscuro. */
body.page a {
    color: #93c5fd;
}

body.page a.action {
    color: var(--text);
}

/* Salir de la partida guiada (también en el móvil, donde la barra inferior puede no verse). */
.tutorial-exit {
    flex: none;
    padding: 5px 10px;
    font-size: 0.82rem;
    color: #fecaca;
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid rgba(252, 165, 165, 0.5);
    background: rgba(185, 28, 28, 0.25);
}

.tutorial-exit:hover {
    background: rgba(185, 28, 28, 0.45);
}
