#gameMenuRoot {
    position: fixed;
    inset: 0 auto auto 0;
    z-index: 2000;
    font-family: "PingFang TC", "Heiti TC", "Microsoft JhengHei", sans-serif;
}

.game-menu-toggle {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    left: max(14px, env(safe-area-inset-left));
    width: 52px;
    height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.58);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255, 214, 102, 0.9), rgba(102, 126, 234, 0.78));
    box-shadow: 0 14px 34px rgba(41, 31, 84, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(14px);
    cursor: pointer;
    transition: transform 0.22s ease, background 0.22s ease, opacity 0.22s ease;
}

.game-menu-toggle:active {
    transform: scale(0.96);
}


body[data-game]:not([data-challenge-game]) .game-container {
    padding-top: max(82px, calc(76px + env(safe-area-inset-top)));
}

body[data-game]:not([data-challenge-game]) .game-container > .game-title {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    left: calc(max(14px, env(safe-area-inset-left)) + 52px + 12px);
    right: calc(max(16px, env(safe-area-inset-right)) + 46px + 12px);
    z-index: 1100;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0 4px;
    color: #fff;
    font-size: var(--game-title-fitted-size, clamp(12px, 3.6vw, 23px));
    font-weight: 900;
    line-height: 1.12;
    letter-spacing: 0.03em;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.36);
    pointer-events: none;
}

.game-menu-toggle span {
    width: 24px;
    height: 3px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.game-menu-toggle.open span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.game-menu-toggle.open span:nth-child(2) {
    opacity: 0;
}

.game-menu-toggle.open span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.game-menu-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: min(84vw, 342px);
    height: 100vh;
    min-height: 100dvh;
    padding: calc(24px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
    border-radius: 0 30px 30px 0;
    border-right: 1px solid rgba(255, 255, 255, 0.42);
    background:
        radial-gradient(circle at 18% 10%, rgba(255, 214, 102, 0.42), transparent 34%),
        radial-gradient(circle at 82% 0%, rgba(116, 185, 255, 0.38), transparent 34%),
        linear-gradient(155deg, rgba(92, 74, 185, 0.98) 0%, rgba(103, 126, 234, 0.96) 52%, rgba(118, 75, 162, 0.96) 100%);
    box-shadow: 22px 0 60px rgba(34, 24, 77, 0.42);
    transform: translateX(-108%);
    opacity: 0.98;
    pointer-events: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.25, 1), opacity 0.22s ease;
}

.game-menu-panel.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.game-menu-title {
    display: grid;
    gap: 5px;
    margin: 8px 46px 16px 0;
    color: #fff;
    text-align: left;
    letter-spacing: 0.04em;
}

.game-menu-title strong {
    font-size: 24px;
    line-height: 1.15;
}

.game-menu-title-kicker {
    width: fit-content;
    padding: 5px 10px;
    border-radius: 999px;
    color: #5f3dc4;
    background: rgba(255, 255, 255, 0.86);
    font-size: 12px;
    font-weight: 900;
}

.game-menu-subtitle {
    margin: 18px 0 10px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.24);
    color: rgba(255, 255, 255, 0.88);
    font-size: 13px;
    font-weight: 900;
    text-align: center;
}

.game-menu-list {
    display: grid;
    gap: 9px;
}

.game-menu-link,
.game-menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 13px 16px;
    margin-top: 9px;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.92) 0%, rgba(255, 126, 95, 0.9) 100%);
    font-size: 16px;
    font-weight: 900;
    line-height: 1.25;
    text-decoration: none;
    text-align: center;
    letter-spacing: 0.03em;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 12px 24px rgba(31, 24, 75, 0.18);
    transition: background 0.22s ease, color 0.22s ease, transform 0.22s ease, box-shadow 0.22s ease;
}

.game-menu-link:first-of-type {
    margin-top: 0;
}

.game-menu-link:hover,
.game-menu-link:focus,
.game-menu-button:hover,
.game-menu-button:focus {
    background: linear-gradient(135deg, rgba(255, 240, 196, 0.98) 0%, rgba(255, 143, 112, 0.96) 100%);
    color: #4b2f7f;
    transform: translateX(2px);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32), 0 12px 26px rgba(31, 24, 75, 0.22);
}

.game-menu-link.active {
    color: #fff;
    background: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%);
    box-shadow: 0 8px 20px rgba(54, 209, 220, 0.3);
}

.game-menu-button {
    border: 0;
    font-family: inherit;
    cursor: pointer;
}

.game-menu-auth-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 9px;
}

.game-menu-auth-row .game-menu-link,
.game-menu-auth-row .game-menu-button {
    width: 100%;
    min-height: 40px;
    margin-top: 0;
    padding: 9px 6px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.1;
    letter-spacing: 0;
}

.game-menu-link.tone-sunset { background: linear-gradient(135deg, #ffb347 0%, #ff7b54 100%); }
.game-menu-link.tone-ocean { background: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%); }
.game-menu-link.tone-mint { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.game-menu-link.tone-grape { background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%); }
.game-menu-link.tone-gold { background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); }
.game-menu-link.tone-rose { background: linear-gradient(135deg, #ff758c 0%, #ff7eb3 100%); }
.game-menu-link.tone-library { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.game-menu-link.tone-challenge { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.game-menu-link.tone-logout {
    margin-top: auto;
    background: linear-gradient(135deg, rgba(60, 54, 107, 0.92) 0%, rgba(33, 37, 41, 0.9) 100%);
}

.game-menu-language-title {
    margin-top: 16px;
    margin-bottom: 8px;
}

.game-menu-language-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-top: 0;
}

.game-menu-language-button {
    min-height: 40px;
    border: 0;
    border-radius: 14px;
    color: #4b2f7f;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34), 0 8px 18px rgba(31, 24, 75, 0.14);
    font-family: inherit;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.game-menu-language-button.active,
.game-menu-language-button[aria-pressed="true"] {
    color: #fff;
    background: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%);
}

.game-menu-language-button:hover,
.game-menu-language-button:focus-visible {
    transform: translateY(-1px);
    outline: none;
}

.game-menu-button:disabled {
    opacity: 0.7;
    cursor: wait;
    transform: none;
}

.game-menu-close {
    position: absolute;
    top: calc(16px + env(safe-area-inset-top));
    right: 16px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 14px;
    color: #5f3dc4;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 8px 18px rgba(70, 56, 120, 0.12);
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.game-menu-mask {
    position: fixed;
    inset: 0;
    z-index: 1999;
    display: block;
    background: rgba(28, 20, 61, 0.42);
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(2px);
    transition: opacity 0.24s ease;
}

.game-menu-mask.open {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 560px) {
    .game-menu-panel {
        width: min(88vw, 324px);
        border-radius: 0 24px 24px 0;
    }

    .game-menu-auth-row {
        gap: 7px;
    }

    .game-menu-auth-row .game-menu-link,
    .game-menu-auth-row .game-menu-button {
        min-height: 38px;
        padding: 8px 4px;
        font-size: 13px;
    }
}
