.game-fullscreen-toggle {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border: 1px solid rgba(68, 215, 208, 0.54);
    border-radius: 8px;
    padding: 0;
    background:
        radial-gradient(circle at 50% 45%, rgba(68, 215, 208, 0.18), transparent 58%),
        rgba(5, 16, 21, 0.82);
    color: #dffffb;
    box-shadow:
        0 0 16px rgba(68, 215, 208, 0.12),
        inset 0 1px 0 rgba(255, 247, 221, 0.14);
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.game-fullscreen-toggle[hidden] {
    display: none !important;
}

.game-fullscreen-toggle:hover,
.game-fullscreen-toggle:focus-visible {
    border-color: rgba(246, 199, 74, 0.86);
    box-shadow:
        0 0 20px rgba(246, 199, 74, 0.2),
        inset 0 1px 0 rgba(255, 247, 221, 0.2);
    transform: translateY(-1px);
    outline: none;
}

.game-fullscreen-toggle.is-active {
    border-color: rgba(246, 199, 74, 0.88);
    background:
        radial-gradient(circle at 50% 45%, rgba(246, 199, 74, 0.22), transparent 58%),
        rgba(17, 20, 12, 0.88);
    color: #ffe6a0;
}

.game-fullscreen-toggle.is-error {
    border-color: rgba(220, 47, 39, 0.9);
    animation: fullscreen-control-error 280ms ease 2;
}

.game-fullscreen-icon {
    position: relative;
    display: block;
    width: 18px;
    height: 18px;
}

.game-fullscreen-icon i {
    position: absolute;
    width: 7px;
    height: 7px;
    border-color: currentColor;
    border-style: solid;
    transition: transform 160ms ease;
}

.game-fullscreen-icon i:nth-child(1) {
    top: 0;
    left: 0;
    border-width: 2px 0 0 2px;
}

.game-fullscreen-icon i:nth-child(2) {
    top: 0;
    right: 0;
    border-width: 2px 2px 0 0;
}

.game-fullscreen-icon i:nth-child(3) {
    right: 0;
    bottom: 0;
    border-width: 0 2px 2px 0;
}

.game-fullscreen-icon i:nth-child(4) {
    bottom: 0;
    left: 0;
    border-width: 0 0 2px 2px;
}

.game-fullscreen-toggle.is-active .game-fullscreen-icon i:nth-child(1) {
    transform: translate(3px, 3px);
}

.game-fullscreen-toggle.is-active .game-fullscreen-icon i:nth-child(2) {
    transform: translate(-3px, 3px);
}

.game-fullscreen-toggle.is-active .game-fullscreen-icon i:nth-child(3) {
    transform: translate(-3px, -3px);
}

.game-fullscreen-toggle.is-active .game-fullscreen-icon i:nth-child(4) {
    transform: translate(3px, -3px);
}

@keyframes fullscreen-control-error {
    50% { transform: translateX(2px); }
}

/* En escritorio y tablet horizontal, la pantalla completa funciona como un
   escenario: la cabecera conserva los controles y el tablero ocupa el mayor
   rectangulo 16:9 posible sin ampliar los fondos mas alla de 1600px. */
@media (min-width: 1101px), (min-width: 761px) and (orientation: landscape) {
    html.is-game-fullscreen,
    html.is-game-fullscreen body {
        width: 100%;
        height: 100%;
        min-height: 100svh;
        overflow: hidden;
    }

    html.is-game-fullscreen body {
        display: grid;
        grid-template-rows: 52px minmax(0, 1fr);
    }

    html.is-game-fullscreen .game-header {
        align-self: stretch;
        width: 100%;
        max-width: none;
        height: 52px;
        min-height: 52px;
        margin: 0;
        padding: 4px 18px;
    }

    html.is-game-fullscreen .game-header__actions {
        flex-wrap: nowrap;
        gap: 6px;
    }

    html.is-game-fullscreen .goose-game {
        display: grid;
        width: 100%;
        max-width: none;
        height: 100%;
        min-height: 0;
        margin: 0;
        padding: 8px 12px 12px;
    }

    html.is-game-fullscreen .game-table,
    html.is-game-fullscreen .game-layout,
    html.is-game-fullscreen .board-scroll {
        width: 100%;
        height: 100%;
        min-height: 0;
    }

    html.is-game-fullscreen .game-table {
        padding: 0;
    }

    html.is-game-fullscreen .game-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
    }

    html.is-game-fullscreen .board-scroll {
        display: grid;
        place-items: center;
        overflow: hidden;
    }

    html.is-game-fullscreen .space-game-board {
        width: min(1600px, calc(100vw - 24px));
        max-width: 1600px;
        height: auto;
        max-height: none;
        margin: auto;
        aspect-ratio: 16 / 9;
    }

    @supports (height: 100dvh) {
        html.is-game-fullscreen,
        html.is-game-fullscreen body {
            min-height: 100dvh;
        }
    }
}

/* En formatos 16:9 o mas anchos manda la altura disponible. Definir solo el
   alto permite que aspect-ratio calcule el ancho sin deformar el tablero. */
@media (min-width: 1101px) and (min-aspect-ratio: 16/9),
       (min-width: 761px) and (max-width: 1100px) and (orientation: landscape) and (min-aspect-ratio: 16/9) {
    html.is-game-fullscreen .space-game-board {
        width: auto;
        max-width: calc(100vw - 24px);
        height: min(900px, calc(100svh - 72px));
        max-height: 900px;
    }

    @supports (height: 100dvh) {
        html.is-game-fullscreen .space-game-board {
            height: min(900px, calc(100dvh - 72px));
        }
    }
}

@media (max-width: 760px) and (orientation: portrait) {
    .game-header__actions > .game-fullscreen-toggle {
        display: none !important;
    }

    html.fullscreen-supported .mobile-command-console__actions {
        grid-template-columns: 1.15fr 0.85fr 0.95fr 44px;
    }

    .mobile-command-console__actions > .game-fullscreen-toggle {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .mobile-command-console__actions > .online-only-action:not(.is-hidden) {
        grid-column: 1 / -1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .game-fullscreen-toggle,
    .game-fullscreen-icon i {
        transition: none;
    }

    .game-fullscreen-toggle.is-error {
        animation: none;
    }
}
