/* The frame of the site: the menu on the top, the content, the footer.
   html.mg-site: every page but the game play page (html.mg-game), whose games count with the 51px game menu
-------------------------------------------------- */
:root {
    --mg-nav-h: 51px;
    --mg-chrome-bg: #10141f;
    --mg-chrome-bg-raised: #181d2c;
    --mg-chrome-line: rgba(255, 255, 255, 0.09);
    --mg-chrome-text: rgba(255, 255, 255, 0.74);
    --mg-chrome-text-muted: rgba(255, 255, 255, 0.56);
    --mg-accent: linear-gradient(135deg, #22d3ee 0%, #6366f1 52%, #ec4899 100%);
    --mg-focus: #9ea2ff;
}

html.mg-site {
    --mg-nav-h: 3.5rem;
}

/* only the body hides the horizontal overflow: it goes to the viewport then, and the body is no scroll container,
   so the address bar of a phone can hide and the page scroll can be locked under the open menu panel */
html.mg-site body {
    min-height: 100%;
    overflow-x: hidden;
}

html.mg-game,
html.mg-game body {
    overflow-x: hidden;
}

html.mg-game #gameMenu > .container-fluid {
    flex-wrap: nowrap;
}

.mg-game-save-status {
    position: absolute;
    pointer-events: none;
}

.mg-game-save-status[data-state] {
    position: static;
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 0.4rem;
    margin-inline: auto 0.65rem;
    padding: 0.25rem 0.55rem;
    border: 1px solid rgba(165, 180, 252, 0.28);
    border-radius: 999px;
    background: var(--mg-chrome-bg);
    color: #eef0fb;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.15;
    white-space: nowrap;
}

.mg-game-save-icon {
    display: none;
    flex: none;
    width: 0.875rem;
    height: 0.875rem;
    color: #b6c5ff;
    font-size: 0.875rem;
    line-height: 1;
    text-align: center;
}

.mg-game-save-status[data-state="pending"] .mg-game-save-spinner {
    display: block;
    border: 1.5px solid rgba(165, 180, 252, 0.28);
    border-top-color: currentColor;
    border-right-color: currentColor;
    border-radius: 50%;
    animation: mg-game-save-spin 0.85s linear infinite;
}

.mg-game-save-status[data-state="success"] .bi-check2,
.mg-game-save-status[data-state="failed"] .bi-exclamation-circle {
    display: block;
}

.mg-game-save-status[data-state="failed"] .bi-exclamation-circle {
    color: #efc695;
}

@keyframes mg-game-save-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .mg-game-save-status[data-state="pending"] .mg-game-save-spinner {
        animation: none;
    }
}

@media (min-width: 992px) {
    html.mg-game #gameMenu .navbar-collapse {
        display: contents !important;
    }

    .mg-game-save-status {
        order: 1;
    }

    .mg-game-menu-exit {
        order: 2;
    }
}

/* the content grows, so on a short page the footer is still at the bottom of the screen */
.mg-content {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

/* the login and registration forms: not glued to the menu and the footer on a small screen */
.mg-content:has(> .index-form) {
    padding: 1.25rem 0.75rem;
}

/* a 4K screen without scaling: everything grows with the screen (the site is in rem) instead of being tiny */
@media (min-width: 1400px) {
    html.mg-site .container,
    html.mg-site .container-xxl {
        max-width: 82.5rem;
    }
}

@media (min-width: 2000px) {
    html.mg-site {
        font-size: clamp(16px, min(0.68vw, 1.25vh), 28px);
    }
}

/* the brand, in the menu, the menu panel and the footer */
.mg-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
}

.mg-brand:hover,
.mg-brand:focus {
    color: #fff;
}

.mg-brand-mark {
    display: inline-grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    flex-shrink: 0;
    border-radius: 0.6rem;
    background: var(--mg-accent);
    color: #fff;
    font-size: 1.25rem;
    box-shadow: 0 0.25rem 0.9rem rgba(99, 102, 241, 0.45);
}

/* the buttons on the dark frame */
.mg-btn-ghost,
.mg-btn-primary {
    --bs-btn-padding-y: 0.4rem;
    --bs-btn-padding-x: 0.9rem;
    --bs-btn-font-weight: 500;
    --bs-btn-border-radius: 0.6rem;
    --bs-btn-focus-shadow-rgb: 158, 162, 255;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    white-space: nowrap;
}

.mg-btn-ghost {
    --bs-btn-color: rgba(255, 255, 255, 0.86);
    --bs-btn-border-color: rgba(255, 255, 255, 0.16);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: rgba(255, 255, 255, 0.08);
    --bs-btn-hover-border-color: rgba(255, 255, 255, 0.3);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: rgba(255, 255, 255, 0.14);
    --bs-btn-active-border-color: rgba(255, 255, 255, 0.3);
}

.mg-btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-border-color: transparent;
    --bs-btn-font-weight: 600;
    background: var(--mg-accent);
    background-size: 160% 100%;
    box-shadow: 0 0.35rem 1rem rgba(99, 102, 241, 0.35);
    transition: background-position 0.3s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.mg-btn-primary:hover,
.mg-btn-primary:focus-visible {
    background-position: 100% 0;
    box-shadow: 0 0.5rem 1.3rem rgba(236, 72, 153, 0.35);
    transform: translateY(-1px);
}

.mg-flag {
    width: 1.25rem;
    height: 0.9375rem;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 0.15rem;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.mg-avatar {
    display: inline-grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--mg-accent);
    color: #fff;
    font-size: 0.95rem;
}

.mg-user-name {
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* the language switch of the menu panel and the footer */
.mg-lang-switch {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.25rem;
    border: 1px solid var(--mg-chrome-line);
    border-radius: 0.7rem;
    background: rgba(255, 255, 255, 0.05);
}

.mg-lang-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--mg-chrome-text);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.mg-lang-option:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
}

.mg-lang-option.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

/* the menu
-------------------------------------------------- */
.mg-navbar {
    --bs-navbar-padding-y: 0;
    --bs-navbar-color: var(--mg-chrome-text);
    --bs-navbar-hover-color: #fff;
    --bs-navbar-active-color: #fff;
    --bs-navbar-nav-link-padding-x: 0.85rem;
    height: var(--mg-nav-h);
    background: var(--mg-chrome-bg);
    box-shadow: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.35);
}

/* no filter or transform on the navbar: the menu panel in it is fixed to the screen */
.mg-navbar::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--mg-accent);
    opacity: 0.9;
    pointer-events: none;
}

/* the navbar is lifted over the backdrop while the menu panel is open, so it is darkened like the backdrop */
.mg-navbar.mg-menu-open {
    z-index: 1046;
}

.mg-navbar::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: #000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s linear, visibility 0.15s linear;
}

.mg-navbar.mg-menu-open::before {
    opacity: 0.5;
    visibility: visible;
}

/* a .container: the menu has the same edges as the content and the footer */
.mg-navbar-inner {
    height: 100%;
    flex-wrap: nowrap;
}

.mg-navbar .navbar-brand {
    margin-right: 1.75rem;
    padding: 0;
}

.mg-toggler {
    padding: 0.2rem 0.45rem;
    border: 0;
    border-radius: 0.55rem;
    color: #fff;
    font-size: 1.85rem;
    line-height: 1;
}

.mg-toggler:hover {
    background: rgba(255, 255, 255, 0.08);
}

.mg-toggler:focus {
    box-shadow: none;
}

.mg-navbar a:focus-visible,
.mg-navbar button:focus-visible,
.mg-footer a:focus-visible,
.mg-footer button:focus-visible {
    outline: 2px solid var(--mg-focus);
    outline-offset: 2px;
    box-shadow: none;
}

.mg-nav {
    gap: 0.25rem;
}

.mg-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border-radius: 0.6rem;
    font-weight: 500;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.mg-nav .nav-link i {
    font-size: 1.05em;
    opacity: 0.85;
}

.mg-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.07);
}

.mg-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.13);
}

.mg-nav .nav-link.active i {
    opacity: 1;
}

.mg-nav-end {
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.mg-lang-toggle,
.mg-user-toggle {
    border-color: transparent;
}

.mg-user-toggle {
    padding-left: 0.35rem;
}

.mg-user-toggle.active {
    background: rgba(255, 255, 255, 0.13);
}

.mg-dropdown {
    --bs-dropdown-bg: var(--mg-chrome-bg-raised);
    --bs-dropdown-border-color: var(--mg-chrome-line);
    --bs-dropdown-border-radius: 0.8rem;
    --bs-dropdown-min-width: 13rem;
    --bs-dropdown-padding-y: 0.4rem;
    --bs-dropdown-spacer: 0.6rem;
    --bs-dropdown-item-padding-y: 0.5rem;
    --bs-dropdown-item-padding-x: 0.75rem;
    --bs-dropdown-link-color: rgba(255, 255, 255, 0.85);
    --bs-dropdown-link-hover-bg: rgba(255, 255, 255, 0.08);
    --bs-dropdown-link-active-color: #fff;
    --bs-dropdown-link-active-bg: rgba(99, 102, 241, 0.4);
    --bs-dropdown-header-color: var(--mg-chrome-text-muted);
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.5);
}

.mg-dropdown .dropdown-header {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mg-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: auto;
    margin: 0 0.4rem;
    border-radius: 0.5rem;
}

.mg-dropdown .mg-check {
    margin-left: auto;
    visibility: hidden;
}

.mg-dropdown .dropdown-item.active .mg-check {
    visibility: visible;
}

.mg-navbar .mg-logout {
    color: #ff9db0;
}

.mg-navbar .mg-logout:hover {
    color: #ffc1cd;
}

/* below lg: the menu is a panel sliding in from the right */
@media (max-width: 991.98px) {
    .mg-offcanvas {
        --bs-offcanvas-width: min(21rem, 88vw);
        --bs-offcanvas-bg: var(--mg-chrome-bg);
        --bs-offcanvas-color: #fff;
        --bs-offcanvas-border-color: var(--mg-chrome-line);
        box-shadow: -1rem 0 3rem rgba(0, 0, 0, 0.5);
    }

    .mg-offcanvas .offcanvas-header {
        height: var(--mg-nav-h);
        flex-shrink: 0;
        padding: 0 1rem 0 1.25rem;
        border-bottom: 1px solid var(--mg-chrome-line);
    }

    .mg-offcanvas .offcanvas-body {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 0.75rem calc(1.5rem + env(safe-area-inset-bottom));
    }

    .mg-offcanvas .mg-nav .nav-link {
        padding: 0.65rem 0.9rem;
        font-size: 1.05rem;
    }

    .mg-offcanvas .mg-nav .nav-link i {
        width: 1.25rem;
        text-align: center;
    }

    .mg-panel-section {
        padding-top: 1rem;
        border-top: 1px solid var(--mg-chrome-line);
    }

    .mg-panel-title {
        margin: 0 0.9rem 0.6rem;
        color: var(--mg-chrome-text-muted);
        font-size: 0.75rem;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .mg-panel-user {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        padding: 0.25rem 0.9rem 0.6rem;
        font-weight: 600;
    }

    .mg-panel-user .mg-user-name {
        max-width: none;
    }

    .mg-panel-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        padding: 0 0.25rem;
    }

    .mg-panel-buttons .btn {
        --bs-btn-padding-y: 0.6rem;
    }

    .mg-offcanvas .mg-lang-switch {
        display: flex;
        margin: 0 0.25rem;
    }

    .mg-offcanvas .mg-lang-option {
        flex: 1;
        padding: 0.6rem 0.75rem;
    }
}

@media (min-width: 992px) {
    .navbar-expand-lg .mg-offcanvas .offcanvas-body {
        flex-grow: 1;
        align-items: center;
    }
}

/* the footer
-------------------------------------------------- */
.mg-footer {
    position: relative;
    padding: 2.75rem 0 1.25rem;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
    background: var(--mg-chrome-bg);
    color: var(--mg-chrome-text);
    font-size: 0.95rem;
}

.mg-footer::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 2px;
    background: var(--mg-accent);
    opacity: 0.9;
}

.mg-footer-tagline {
    max-width: 26rem;
    margin: 1rem 0 1.25rem;
    line-height: 1.6;
}

.mg-footer-title {
    margin-bottom: 0.9rem;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mg-footer-links {
    display: grid;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mg-footer-links a {
    display: inline-block;
    padding: 0.2rem 0;
    color: var(--mg-chrome-text);
    text-decoration: none;
    transition: color 0.15s ease;
}

.mg-footer-links a:hover,
.mg-footer-links a.active {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 0.25em;
}

.mg-footer-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--mg-chrome-line);
}

.mg-footer-copy {
    margin: 0 auto 0 0;
    color: var(--mg-chrome-text-muted);
    font-size: 0.875rem;
}

.mg-back-to-top {
    display: inline-grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    background: transparent;
    color: #fff;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.mg-back-to-top:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
}

@media (pointer: coarse) {
    .mg-footer-links a {
        padding: 0.4rem 0;
    }
}

@media (max-width: 767.98px) {
    .mg-footer {
        padding-top: 2.25rem;
    }

    .mg-footer-bottom {
        margin-top: 2rem;
    }
}
#gameMenu .logoImage.localized-game-menu:not(:lang(en)) span {
    display: none;
}

#gameMenu .logoImage.localized-game-menu:lang(en) {
    display: flex;
    align-items: center;
    width: auto;
    padding-bottom: 0;
    background-image: none;
    font-weight: 700;
}
