.player-menu {
    position: fixed;
    inset: 0;
    z-index: 1200;

    display: grid;
    place-items: start center;

    overflow-y: auto;

    padding:
        max(20px, env(safe-area-inset-top))
        14px
        max(20px, env(safe-area-inset-bottom));

    background:
        rgba(2, 7, 16, 0.78);

    backdrop-filter:
        blur(14px);
}

.player-menu[hidden] {
    display: none;
}

.player-menu__panel {
    width: min(100%, 620px);

    margin-block: auto;

    padding: clamp(18px, 4vw, 32px);

    border:
        1px solid
        rgba(160, 203, 255, 0.24);

    border-radius: 22px;

    background:
        rgba(5, 13, 27, 0.96);

    box-shadow:
        0 24px 80px
        rgba(0, 0, 0, 0.48);
}

.player-menu__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 16px;
}

.player-menu__header h2 {
    margin: 0;
}

.player-menu__close {
    min-width: 44px;
    min-height: 44px;

    border-radius: 50%;
}

.player-menu__section {
    margin-top: 22px;
}

.player-menu__section h3 {
    margin-bottom: 10px;
}

.player-menu__field {
    display: grid;
    gap: 8px;
}

.player-menu__field input,
.player-menu__field select {
    width: 100%;
    min-height: 46px;

    padding: 10px 12px;
}

.player-menu__help {
    margin: 8px 0 0;

    opacity: 0.72;

    line-height: 1.45;
}

.player-menu__avatars {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 10px;
}

.player-menu__avatar {
    min-height: 72px;
}

.player-menu__avatar.is-selected {
    outline:
        2px solid currentColor;

    outline-offset: 2px;
}

.player-menu__actions {
    display: flex;
    justify-content: flex-end;

    margin-top: 26px;
}

.player-menu__actions button {
    min-height: 46px;

    padding-inline: 18px;
}

.player-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;

    margin-left: auto;
}

.player-toolbar button {
    min-height: 42px;

    padding-inline: 12px;
}

@media (max-width: 600px) {
    .player-menu__avatars {
        grid-template-columns: 1fr;
    }

    .player-toolbar {
        gap: 6px;
    }

    .player-toolbar button {
        padding-inline: 10px;
    }
}


.player-menu__save-actions {
    display: grid;
    grid-template-columns:
        repeat(
            2,
            minmax(0, 1fr)
        );

    gap:
        0.65rem;

    margin-top:
        0.8rem;
}


.player-menu__save-actions button {
    min-height:
        44px;

    padding:
        0.65rem
        0.8rem;

    border:
        1px solid
        rgba(205, 215, 255, 0.28);

    border-radius:
        0.7rem;

    background:
        rgba(26, 35, 61, 0.92);

    color:
        #ffffff;

    font:
        inherit;

    font-weight:
        700;

    cursor:
        pointer;
}


@media (max-width: 600px) {
    .player-menu__save-actions {
        grid-template-columns:
            1fr;
    }
}


/*
 * Profile & Options primary action.
 *
 * Adventure save controls above manage the current game snapshot.
 * This footer action persists the player's profile/preferences.
 * Keep the two concepts visually distinct.
 */
.player-menu__actions {
    position: sticky;
    bottom: 0;

    z-index: 2;

    padding-top: 16px;
    padding-bottom:
        max(
            4px,
            env(safe-area-inset-bottom)
        );

    background:
        linear-gradient(
            to bottom,
            rgba(5, 13, 27, 0),
            rgba(5, 13, 27, 0.98) 24%
        );
}


.player-menu__actions button[data-player-save] {
    width: 100%;

    min-height: 52px;

    border:
        1px solid
        rgba(205, 215, 255, 0.55);

    border-radius: 0.75rem;

    background:
        rgba(48, 67, 116, 0.98);

    color: #ffffff;

    font: inherit;
    font-weight: 800;

    cursor: pointer;
}


/* =========================================================
   Study topic selection
   ========================================================= */

.player-menu__study-topics {
    display: grid;
    gap: 10px;

    margin-top: 12px;
}

.player-menu__study-group {
    border:
        1px solid
        rgba(156, 188, 218, 0.18);

    border-radius: 12px;

    padding: 10px 12px;

    background:
        rgba(6, 18, 34, 0.34);
}

.player-menu__study-group summary {
    cursor: pointer;

    font-weight: 700;

    color:
        rgba(245, 247, 251, 0.96);
}

.player-menu__study-group
.player-menu__help {
    margin:
        8px 0 10px;
}

.player-menu__study-option {
    display: flex;
    align-items: center;

    gap: 10px;

    min-height: 40px;

    padding: 6px 4px;

    cursor: pointer;
}

.player-menu__study-option input {
    width: 18px;
    height: 18px;
}

.player-menu__study-option span {
    color:
        rgba(230, 238, 248, 0.88);
}


/* =========================================================
   QueenK Study settings
   ========================================================= */

.player-menu__section-heading,
.player-menu__study-topic-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 16px;
}


.player-menu__study-topic-header {
    cursor: pointer;
}


.player-menu__study-topic-title {
    min-width: 0;
}


.queenk-switch {
    position: relative;

    flex: 0 0 auto;

    width: 52px;
    height: 30px;

    cursor: pointer;
}


.queenk-switch input {
    position: absolute;

    width: 1px;
    height: 1px;

    opacity: 0;
}


.queenk-switch__track {
    position: absolute;

    inset: 0;

    border-radius: 999px;

    border:
        1px solid
        rgba(
            255,
            255,
            255,
            0.18
        );

    background:
        rgba(
            255,
            255,
            255,
            0.14
        );

    transition:
        background 160ms ease,
        border-color 160ms ease;
}


.queenk-switch__track::after {
    content: "";

    position: absolute;

    top: 3px;
    left: 3px;

    width: 22px;
    height: 22px;

    border-radius: 50%;

    background: white;

    box-shadow:
        0 2px 6px
        rgba(
            0,
            0,
            0,
            0.35
        );

    transition:
        transform 160ms ease;
}


.queenk-switch input:checked
+ .queenk-switch__track {
    background:
        rgb(
            55,
            145,
            239
        );

    border-color:
        rgba(
            104,
            185,
            255,
            0.92
        );
}


.queenk-switch input:checked
+ .queenk-switch__track::after {
    transform:
        translateX(22px);
}


.queenk-switch input:focus-visible
+ .queenk-switch__track {
    outline:
        2px solid
        rgba(
            120,
            194,
            255,
            0.95
        );

    outline-offset: 3px;
}


.player-menu__study-topic-body {
    padding:
        4px 14px
        14px;
}


.player-menu__study-topic-body.is-disabled {
    opacity: 0.42;
}


.player-menu__study-subtopic {
    display: flex;

    align-items: center;

    gap: 10px;

    margin:
        9px 0;
}


.study-source-heading {
    display: block;

    margin-top: 14px;

    opacity: 0.68;

    font-weight: 600;
}


.study-source-links {
    display: grid;

    gap: 5px;

    margin-top: 6px;
}


.study-source-links a {
    width: fit-content;

    color: #8fcaff;

    font-size: 0.8rem;

    text-decoration: underline;

    text-underline-offset: 2px;
}


.study-content-notice {
    margin:
        12px 0 18px;

    padding: 14px;

    border:
        1px solid
        rgba(
            127,
            179,
            220,
            0.2
        );

    border-radius: 12px;

    background:
        rgba(
            7,
            24,
            42,
            0.54
        );
}


.study-content-notice p {
    margin:
        7px 0;

    line-height: 1.42;

    font-size: 0.82rem;
}


.study-content-notice summary {
    margin-top: 10px;

    cursor: pointer;

    color: #dcecff;
}


.player-menu__study-locked {
    flex: 0 0 auto;

    padding:
        5px 10px;

    border:
        1px solid
        rgba(156, 188, 218, 0.28);

    border-radius:
        999px;

    color:
        rgba(220, 230, 242, 0.68);

    font-size:
        0.72rem;

    font-weight:
        800;

    letter-spacing:
        0.08em;
}


/* =========================================================
   Study categories
   ========================================================= */

.player-menu__study-category {
    display: grid;

    gap: 10px;
}


.player-menu__study-category
+ .player-menu__study-category {
    margin-top: 22px;

    padding-top: 18px;

    border-top:
        1px solid
        rgba(
            156,
            188,
            218,
            0.14
        );
}


.player-menu__study-category-heading {
    margin:
        0 0 2px;

    color:
        rgba(
            225,
            237,
            249,
            0.92
        );

    font-size:
        0.82rem;

    font-weight:
        800;

    letter-spacing:
        0.08em;

    text-transform:
        uppercase;
}


/* =========================================================
   Locked Study control

   Deliberately occupies the same control territory as the
   normal 52 x 30 QueenK switch.
   ========================================================= */

.player-menu__study-locked {
    flex:
        0 0 52px;

    width:
        52px;

    height:
        30px;

    display:
        grid;

    place-items:
        center;

    padding:
        0;

    border:
        1px solid
        rgba(
            156,
            188,
            218,
            0.28
        );

    border-radius:
        999px;

    background:
        rgba(
            255,
            255,
            255,
            0.06
        );

    color:
        rgba(
            220,
            230,
            242,
            0.68
        );

    font-size:
        0.58rem;

    font-weight:
        800;

    letter-spacing:
        0.05em;

    cursor:
        default;
}


/* =========================================================
   Study topic interaction affordance
   ========================================================= */

.player-menu__study-topic {
    border:
        1px solid
        rgba(156, 188, 218, 0.12);

    border-radius:
        12px;

    overflow:
        hidden;

    background:
        rgba(7, 19, 34, 0.28);
}


.player-menu__study-topic-header {
    display:
        grid;

    grid-template-columns:
        minmax(0, 1fr)
        auto
        auto;

    gap:
        10px;

    align-items:
        center;

    min-height:
        52px;

    padding:
        10px 12px;

    cursor:
        pointer;
}


.player-menu__study-topic-header:hover {
    background:
        rgba(255, 255, 255, 0.035);
}


.player-menu__study-topic[data-locked="true"]
.player-menu__study-topic-header {
    cursor:
        default;
}


.player-menu__study-topic[data-locked="true"]
.player-menu__study-topic-header:hover {
    background:
        transparent;
}


.player-menu__study-chevron {
    display:
        inline-grid;

    place-items:
        center;

    width:
        22px;

    height:
        22px;

    opacity:
        0.72;

    transition:
        transform 160ms ease;
}


.player-menu__study-topic[open]
.player-menu__study-chevron {
    transform:
        rotate(180deg);
}


.player-menu__study-topic-body {
    padding:
        0 12px 14px;
}


/* =========================================================
   Study activity availability
   ========================================================= */

.player-menu__study-activities {
    display:
        grid;

    gap:
        7px;

    margin:
        12px 0;
}


.player-menu__study-activities > strong {
    font-size:
        0.82rem;

    opacity:
        0.78;
}


.player-menu__study-activity {
    display:
        flex;

    align-items:
        center;

    min-height:
        34px;

    padding:
        7px 10px;

    border-radius:
        8px;

    border:
        1px solid
        rgba(156, 188, 218, 0.14);
}


.player-menu__study-activity.is-available {
    background:
        rgba(70, 139, 214, 0.12);
}


.player-menu__study-activity.is-unavailable {
    opacity:
        0.48;
}
