


/* ═══════════════════════════════════════════════════════════
   PLAYER PROFILE  —  mathProfile.css
   ═══════════════════════════════════════════════════════════ */

/* ── Panel container ──────────────────────────────────────── */
button#headerUserInfo {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    padding: 0;
    border-radius: 0;
}

#mathProfileDiv {
    display: flex;          /* overridden to none below */
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;

    color: var(--color);
    font-family: 'Arial', sans-serif;
    padding: 1.25rem;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.7);
    background-color: var(--bgcolor);

    position: fixed;
    top: calc(var(--header-height, 60px) * 1.5);
    left: 50%;
    transform: translateX(-50%);
    width: clamp(320px, 62vw, 860px);
    height: calc(100vh - var(--header-height, 60px) * 4);
    max-height: calc(100vh - var(--header-height, 60px) * 4);
    overflow-y: auto;
    z-index: 2;

    display: none;          /* hidden until JS shows it */
}


/* ── Top section: avatar centred ─────────────────────────── */
#profileTopSection {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Captain arrows now live inside #mathAvatarTopWrapper */
.captainChangerButton {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background-repeat: no-repeat;
    background-size: 55%;
    background-position: center;
    background-color: rgba(0, 0, 0, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
    cursor: pointer;
    opacity: 0.9;
    position: relative;
    z-index: 1;
    transition: opacity 0.15s, background-color 0.15s, transform 0.15s;
}
.captainChangerButton:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.9);
    transform: scale(1.08);
}

#leftCaptainChanger,
#rightCaptainChanger,
#mathAvatarShipChooserLeft,
#mathAvatarShipChooserRight {
    background-image: none;
}

#leftCaptainChanger::before,
#rightCaptainChanger::before,
#mathAvatarShipChooserLeft::before,
#mathAvatarShipChooserRight::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid white;
    border-bottom: 2px solid white;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.75));
}

#leftCaptainChanger::before,
#mathAvatarShipChooserLeft::before {
    transform: translate(-35%, -50%) rotate(135deg);
}

#rightCaptainChanger::before,
#mathAvatarShipChooserRight::before {
    transform: translate(-65%, -50%) rotate(-45deg);
}


/* ── Avatar card ──────────────────────────────────────────── */
#mathAvatarWrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    position: relative;
    background-size: cover;
    background-position: center top;
    border-radius: 20px;
    width: clamp(200px, 38vw, 400px);
    aspect-ratio: 1;
    margin-inline: auto;
}

#mathAvatarTopWrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.5rem;
    gap: 0.3rem;
}

#mathAvatarBottomWrapper {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0.5rem;
}

#mathAvatarTopRight { width: 75%; }

.mathAvatarName {
    font-size: 0.85rem;
    font-weight: bold;
    color: white;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
}

#mathAvatarName {
    font-size: clamp(1.2rem, 4vw, 2rem);
    font-weight: bold;
    color: var(--color);
    text-align: center;
}




/* ── Ship chooser circle ──────────────────────────────────── */
#mathAvatarShipChooserWrapper {
    background-image: url("../img/motherships/back_small.avif");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    width: clamp(80px, 14vw, 160px);
    aspect-ratio: 1;
    position: absolute;
    bottom: -2.5rem;
    right: -2rem;
    z-index: 2;
    border-radius: 99%;
    overflow: visible;
}

.mathAvatarCircularChooser {
    border-radius: 99%;
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 80%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: 4%;
}

.mathAvatarShipChooserButton {
    background-repeat: no-repeat;
    background-size: 55%;
    background-position: center;
    background-color: rgba(0, 0, 0, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
    cursor: pointer;
    width: 24%;
    height: 24%;
    padding: 0;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.9;
    z-index: 1;
    transition: opacity 0.15s, background-color 0.15s, transform 0.15s;
}
.mathAvatarShipChooserButton:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.9);
    transform: translateY(-50%) scale(1.08);
}

#mathAvatarShipChooserLeft  {
    left: -10%;
}
#mathAvatarShipChooserRight {
    right: -10%;
}

#mathAvatarShipChooserLeft::before,
#mathAvatarShipChooserRight::before {
    width: 0.4rem;
    height: 0.4rem;
    border-width: 0 2px 2px 0;
}

#mathAvatarShipChooser {
    background-image: url("../img/themes/default_ship_small.avif");
    background-size: 80%;
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#mathAvatarShipChooser[data-theme="green"] {
    background-image: url("../img/themes/green_ship_small.avif");
}


/* ── Info icons row ───────────────────────────────────────── */
#infoIcons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    position: relative;
    z-index: 7;
}

/* Whichever interactive element is hovered should own the top layer. */
#infoIcons:has(.profileInfoIcon:hover) {
    z-index: 30;
}

.profileInfoIcon {
    width: 3.5rem;
    height: 3.5rem;
    background-repeat: no-repeat;
    background-size: 3rem;
    background-position: center;
    position: relative;
    cursor: pointer;
    border-radius: 50%;
    transition: transform 0.15s;
}

.profileInfoIcon:hover { transform: scale(1.1); }

#profileInfoIconCaptain { background-image: url("../img/icons/captain.avif"); }
#profileInfoIconShip    { background-image: url("../img/icons/spaceship.avif"); }
#profileInfoIconMode    { background-image: url("../img/icons/mode.avif"); }


/* ── Active card effects beside the starmap icon ─────────── */
#equippedCardEffects {
    position: fixed;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    /* Keep the effects with the starmap button in the page layer. The open
       starmap (z-index: 2) should cover both of them. */
    z-index: 1;
}

#equippedCardEffects[hidden] {
    display: none;
}

.equippedCardEffect {
    position: relative;
    width: 2.8rem;
    height: 2.8rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    overflow: visible;
    background: rgba(8, 12, 20, 0.72);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    opacity: 0.62;
    transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.equippedCardEffect:hover,
.equippedCardEffect:focus-visible {
    opacity: 1;
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.equippedCardEffectImage {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

.equippedCardEffectTooltip {
    display: none;
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.6rem);
    width: min(17rem, calc(100vw - 2rem));
    padding: 0.65rem 0.75rem;
    transform: translateX(-50%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(8, 8, 10, 0.94);
    color: white;
    font-size: 0.85rem;
    font-weight: normal;
    line-height: 1.3;
    text-align: left;
    pointer-events: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    z-index: 50;
}

.equippedCardEffectTooltip strong,
.equippedCardEffectTooltip span {
    display: block;
}

.equippedCardEffectTooltip strong {
    margin-bottom: 0.25rem;
}

.equippedCardEffect:hover .equippedCardEffectTooltip,
.equippedCardEffect:focus-visible .equippedCardEffectTooltip {
    display: block;
}

@media (orientation: portrait), (max-width: 700px) {
    #equippedCardEffects {
        gap: 0.3rem;
    }

    .equippedCardEffect {
        width: 2.2rem;
        height: 2.2rem;
    }

    .equippedCardEffectTooltip {
        left: 0;
        transform: none;
    }
}

/* Tooltip popups */
#mathAvatarCaptainDesc,
#mathAvatarShipDesc,
#mathAvatarModeDesc {
    display: none;
    position: absolute;
    top: 110%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    width: max(220px, 28vw);
    max-width: 90vw;
    border-radius: 8px;
    padding: 0.75rem;
    color: white;
    font-size: 0.95rem;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#profileInfoIconCaptain:hover #mathAvatarCaptainDesc,
#profileInfoIconShip:hover    #mathAvatarShipDesc,
#profileInfoIconMode:hover    #mathAvatarModeDesc {
    display: block;
}


/* ── Skills + cards wrapper ───────────────────────────────── */
#mathSkillInfoWrapper {
    background-color: rgba(0, 0, 0, 0.08);
    padding: 1rem;
    border-radius: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}

/* Group section spans both columns */
#mathProfileMathGroupWrapperSection {
    grid-column: 1 / -1;
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    max-height: 150px;
    overflow-y: auto;
    border-radius: var(--border-radius, 8px);
    padding: 10px;
    background-color: var(--panel-color);
}

#mathSkillInfoCloseBtn {
    position: sticky;
    top: 0;
    align-self: flex-end;
    z-index: 10;
    font-size: 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
    padding: 0;
    margin-bottom: -1rem;
}

#mathSkillInfoRightWrapper,
#mathSkillInfoLeftWrapper {
    min-width: 0;
}

.mathSkillInfoTitle {
    text-align: center;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.mathSkillInfo { text-align: center; }


/* ── Skill nodes ──────────────────────────────────────────── */
#mathSkillInfoSkillsWrapper {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.mathSkillInfoSkill {
    width: calc((100% - 0.75rem) / 4);
    max-width: 4.5rem;
    min-width: 0;
    border-radius: 5px;
    position: relative;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.mathSkillInfoSkill > svg {
    display: block;
    width: min(100%, 4rem);
    height: auto;
    aspect-ratio: 1;
    flex: none;
}

.mathSkillInfoSkillName {
    width: calc(100% + 0.4rem);
    min-height: 3.3em;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    white-space: normal;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: auto;
    text-wrap: balance;
}

.mathSkillInfoWinrate {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.3rem;
    text-shadow: 0 0 15px rgba(0, 0, 0, 1);
    margin: 0;
}

/* ── Analysis sliders ─────────────────────────────────────── */
#mathSkillInfoAnalysisWrapper {
    padding-left: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid rgba(128,128,128,0.2);
    padding-top: 0.5rem;
}

.mathSkillInfoAnalysisSliderWrapper {
    display: grid;
    grid-template-columns: 2fr 3fr 1fr;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.mathSkillInfoAnalysisSliderWrapper > :first-child {
    text-align: right;
}

.mathSkillInfoAnalysisSlider {
    height: 0.9rem;
    background-color: var(--panel-color);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.mathSkillInfoAnalysisSliderInner {
    background-color: #1b7a67;
    height: 100%;
    border-radius: inherit;
}

.mathSkillInfoAnalysisSliderLeftImg,
.mathSkillInfoAnalysisSliderRightImg {
    width: 2rem;
    height: auto;
}


/* ── Cards (equipped) ─────────────────────────────────────── */
#skillTargetCardWrapper {
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    width: 100%;
    position: relative;
    z-index: 8;
}

.skillTargetCard {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    min-width: 0;
    flex: 1 1 0;
    max-width: 9rem;
    text-align: center;
    box-shadow: 0 0 5px rgba(0, 255, 204, 0.7);
    position: relative;
}

.libraryCardWrapper {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    width: 8rem;
    aspect-ratio: 2 / 3;
    text-align: center;
    box-shadow: 0 0 5px rgba(0, 255, 204, 0.7);
}

.libraryCardWrapper > :first-child,
.skillTargetCard > :first-child {
    transition: transform 0.2s ease, filter 0.2s ease;
    z-index: 5;
}

.skillTargetCard:hover {
    z-index: 20;
}

.skillTargetCard:hover > :first-child {
    transform: scale(1.9) translateY(-22%);
    z-index: 20;
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
}

.skillTargetCard:first-child:hover > :first-child {
    transform-origin: left center;
}

.skillTargetCard:last-child:hover > :first-child {
    transform-origin: right center;
}

.libraryCardWrapper:hover > :first-child {
    transform: scale(2);
    z-index: 6;
}

.libraryCardWrapper:hover > :first-child > p,
.skillTargetCard:hover > :first-child > p {
    display: block;
}

.libraryCardWrapper > :first-child > p,
.skillTargetCard > :first-child > p {
    display: none;
}


/* ── Card inner layout ────────────────────────────────────── */
.profileCardDiv {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 5fr 1fr;
    grid-template-rows: 7fr 13fr 13fr 13fr 4fr 2fr;
    overflow: visible;
    position: relative;
    aspect-ratio: 2 / 3;
    background-repeat: no-repeat;
    background-position: 30% 30%;
    background-size: 95% 90%;
}

.profileCardImg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}

.profileCardDesc {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.85);
    top: 25%;
    width: 75%;
    left: 12.5%;
    border-radius: 5px;
    padding: 0.2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    font-size: xx-small;
    overflow: hidden;
    color: white;
    z-index: 1;
}

.profileCardName {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.6rem;
    font-weight: bold;
    z-index: 0;
    grid-column: 2;
    grid-row: 5;
    text-align: center;
    color: black;
    text-shadow:
        -1px -1px 3px rgba(255, 255, 255, 0.5),
         1px -1px 3px rgba(255, 255, 255, 0.5),
        -1px  1px 3px rgba(255, 255, 255, 0.5),
         1px  1px 3px rgba(255, 255, 255, 0.5),
        -2px  0   3px rgba(255, 255, 255, 0.5),
         2px  0   3px rgba(255, 255, 255, 0.5),
         0   -2px 3px rgba(255, 255, 255, 0.5),
         0    2px 3px rgba(255, 255, 255, 0.5),
         0    0   5px rgba(255, 255, 255, 0.5),
         0    0   8px rgba(255, 255, 255, 0.5);
    overflow: hidden;
    white-space: nowrap;
}

.profileCardIconCommon {
    width: 35%;
    height: auto;
    object-fit: cover;
    margin: auto;
    margin-top: 0;
}

.profileCardIconWrapper {
    min-width: 0;
    min-height: 0;
    position: relative;
}

.profileCardIconWrapper[data-size="35"] > img { width: 35%; }
.profileCardIconWrapper[data-size="50"] > img { width: 50%; }
.profileCardIconWrapper[data-size="75"] > img { width: 75%; }

.profileCardIcon0 { grid-column: 2; grid-row: 2; }
.profileCardIcon1 { grid-column: 2; grid-row: 3; }
.profileCardIcon2 { grid-column: 2; grid-row: 4; }

.profileCardIconLabelCommon {
    font-size: x-small;
    color: white;
    border-radius: 5px;
    position: absolute;
    bottom: 50%;
    margin-inline: auto;
    width: 100%;
}


/* ── Card action buttons ──────────────────────────────────── */
#cardActionsWrapper {
    margin-top: 0.7rem;
    display: flex;
    width: 100%;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 0.4rem;
}

#cardActionsWrapper > button {
    display: flex;
    font-size: 0.95rem;
    font-weight: bold;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.6rem;
}


/* ── Disabled card ────────────────────────────────────────── */
.disabledCard {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(70%);
    transform: scale(0.98);
}


/* ── Unequip button ───────────────────────────────────────── */
.unequipCardBtn {
    position: absolute;
    top: 6px; right: 6px;
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.15), rgba(30, 0, 0, 0.9));
    color: #fff;
    font-size: 16px;
    line-height: 20px;
    cursor: pointer;
    text-align: center;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(2px);
    transition: all 0.25s ease;
}

.unequipCardBtn:hover { background: rgba(255, 50, 50, 0.8); }

.profileCardDiv .unequipCardBtn         { opacity: 0; transition: opacity 0.2s; }
.profileCardDiv:hover .unequipCardBtn   { opacity: 1; }


/* ── Card library modal ───────────────────────────────────── */
#cardLibrary {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 25%;
    width: min(600px, 85vw);
    left: 50%;
    transform: translateX(-50%);
    min-height: 50%;
    border: 3px outset var(--color);
    z-index: 7;
    background-color: var(--bgcolor);
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
}

#cardLibraryInnerWrapper {
    flex-grow: 1;
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 1rem;
}

#cardLibraryCloseBtn {
    margin-inline: auto;
    font-size: 2rem;
    cursor: pointer;
}

.topicProfileCard {
    background-position: center;
    background-size: 95% 90%;
}

.topicProfileCard .profileCardDesc {
    display: none !important;
}

.topicProfileCard > .profileCardImg {
    z-index: 2;
    pointer-events: none;
}

.topicProfileCard > .profileCardName {
    z-index: 3;
}

.topicCardContent {
    position: absolute;
    inset: 15% 12% 22%;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3%;
    pointer-events: none;
}

.topicCardMysticPath {
    position: absolute;
    inset: 2% 3%;
    width: 94%;
    height: 96%;
    z-index: 0;
    overflow: visible;
    opacity: 0.7;
    filter: drop-shadow(0 0 3px rgba(84, 238, 255, 0.9));
}

.topicCardMysticPath polyline {
    stroke: rgba(132, 237, 255, 0.58);
    stroke-width: 1.15;
    stroke-dasharray: 2.5 4;
}

.topicCardMysticPath circle {
    fill: #e6fdff;
    stroke: rgba(124, 76, 255, 0.85);
    stroke-width: 1.2;
}

.topicCardTopic {
    position: relative;
    z-index: 1;
    min-height: 0;
    max-height: 32%;
    flex: 1 1 0;
    display: grid;
    grid-template-columns: 38% minmax(0, 1fr);
    align-items: center;
    gap: 5%;
    padding: 1% 3%;
    overflow: hidden;
}

.topicCardTopic:nth-of-type(2) {
    grid-template-columns: minmax(0, 1fr) 38%;
}

.topicCardTopic:nth-of-type(2) .topicCardSkillLogo {
    grid-column: 2;
}

.topicCardTopic:nth-of-type(2) .topicCardTopicLabel {
    grid-column: 1;
    grid-row: 1;
    text-align: right;
}

.topicCardSkillLogo {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    filter: drop-shadow(0 0 3px rgba(105, 244, 255, 0.85)) drop-shadow(0 0 7px rgba(105, 99, 255, 0.45));
}

.topicCardTopicLabel,
.topicCardEmpty {
    min-width: 0;
    color: #eefcff;
    font-size: clamp(0.34rem, 0.55vw, 0.5rem);
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 600;
    line-height: 1.15;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
    text-align: left;
    letter-spacing: 0.025em;
    text-shadow: 0 1px 2px #000, 0 0 4px rgba(67, 230, 255, 0.75), 0 0 8px rgba(75, 43, 160, 0.65);
}

.topicCardEmpty {
    align-self: center;
    padding: 0.5rem;
    border-radius: 8px;
    background: rgba(3, 12, 22, 0.82);
    text-align: center;
}

.cardActionBtnLocked,
.cardActionBtn:disabled {
    cursor: not-allowed;
    opacity: 0.72;
    filter: saturate(0.65);
}

.cardActionBtnLocked::after {
    content: '🔒';
    margin-inline-start: 0.3rem;
    font-size: 0.8em;
}

#cardLibraryTitle {
    display: flex;
    justify-content: center;
}


/* ── Math group section ───────────────────────────────────── */
#mathProfileMathGroupWrapper {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 90%;
}

#mathProfileMathGroupWrapper .mathGroupListTitle {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

#mathProfileMathGroupWrapper .groupItem {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    min-height: 2rem;
    padding: 0.35rem 0.65rem;
    color: var(--color);
    background: color-mix(in srgb, var(--bgcolor) 72%, transparent);
    border: 1px solid color-mix(in srgb, var(--color) 16%, transparent);
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

#mathProfileMathGroupWrapper .groupItem:not(:disabled):hover,
#mathProfileMathGroupWrapper .groupItem:not(:disabled):focus-visible {
    border-color: color-mix(in srgb, var(--color) 45%, transparent);
    background: color-mix(in srgb, var(--bgcolor) 88%, transparent);
    transform: translateX(2px);
}

#mathProfileMathGroupWrapper .groupItemActive {
    border-color: #22a987;
    background: color-mix(in srgb, #22a987 16%, var(--bgcolor));
}

#mathProfileMathGroupWrapper .groupItem:disabled {
    cursor: wait;
    opacity: 0.75;
}

#mathProfileMathGroupWrapper .groupItemStatus {
    flex: none;
    padding: 0.12rem 0.45rem;
    color: #073e32;
    background: #73e0c2;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}


/* ── Decorative ───────────────────────────────────────────── */
.ribbon-border {
    position: relative;
    display: inline-block;
    border: 5px solid rgb(0, 0, 0);
    border-radius: 20px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.7);
}

.ribbon-border::before, .ribbon-border::after {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    border: 2px solid rgb(179, 61, 192);
    border-radius: 22px;
    pointer-events: none;
}

.ribbon-border::after {
    top: -4px; left: -4px; right: -4px; bottom: -4px;
    border-color: rgb(8, 249, 249);
    border-radius: 24px;
}

.spacedOutLetters {
    letter-spacing: 0.05em;
    line-height: 1.5em;
}


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

/* ── Narrow panel: skills 1-column (≤ 1100px wide) ─────────── */
@media (max-width: 1100px) {
    #mathSkillInfoWrapper {
        grid-template-columns: 1fr;
    }

    #mathProfileMathGroupWrapperSection {
        grid-column: 1;
    }
}
/* ── Smaller laptop screens (≤ 900px tall) — same formula, no gap override needed */
@media (max-height: 900px) and (min-width: 700px) {
    #mathProfileDiv {
        top: calc(var(--header-height, 60px) * 1.5);
        height: calc(100vh - var(--header-height, 60px) * 4);
        max-height: calc(100vh - var(--header-height, 60px) * 4);
    }
}

/* ── Short landscape (wide but short, e.g. 1712×565) ─────────
   Scoped to min-width: 700px so true mobile is untouched.
   Keeps 2-column layout but shrinks everything vertically.   */
@media (max-height: 600px) and (min-width: 700px) {

    #mathProfileDiv {
        top: calc(var(--header-height, 60px) + 0.25rem);
        max-height: calc(100vh - var(--header-height, 60px) - 1rem);
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }

    #mathAvatarWrapper {
        width: clamp(120px, 18vw, 200px);
    }

    #mathAvatarShipChooserWrapper {
        width: clamp(50px, 8vw, 80px);
        bottom: -1.2rem;
        right: -0.8rem;
    }

    .mathAvatarName { font-size: 0.7rem; }

    .profileInfoIcon {
        width: 2.5rem;
        height: 2.5rem;
        background-size: 2rem;
    }

    /* Smaller skill nodes so sliders don't crowd them */
    .mathSkillInfoSkill {
        width: 56px;
        
    }

    .mathSkillInfoWinrate { font-size: 0.9rem; }

    .mathSkillInfoAnalysisSliderWrapper {
        font-size: 0.78rem;
        gap: 0.25rem;
        margin-bottom: 0.2rem;
    }

    #mathSkillInfoWrapper { padding: 0.5rem; gap: 0.5rem; }

    .skillTargetCard { max-width: 80px; }

    #cardActionsWrapper > button {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }

    #mathProfileMathGroupWrapperSection {
        max-height: 80px;
        padding: 4px;
    }
}

/* ── Portrait / narrow mobile ─────────────────────────────── */
@media (orientation: portrait), (max-width: 700px) {

    /* Panel: full width, scrollable */
    #mathProfileDiv {
        width: 96vw;
        box-sizing: border-box;
        top: var(--header-height, 0px);
        height: calc(100vh - var(--header-height, 0px));
        max-height: calc(100vh - var(--header-height, 0px));
        left: 2vw;
        transform: none;
        padding: 0.6rem;
        border-radius: 8px;
        gap: 0.75rem;
    }

    /* Arrow buttons: slightly smaller on mobile */
    .captainChangerButton {
        width: 22px;
        height: 22px;
    }

    /* Avatar card: smaller */
    #mathAvatarWrapper {
        width: clamp(160px, 55vw, 280px);
    }

    /* Ship chooser: scale down */
    #mathAvatarShipChooserWrapper {
        width: clamp(60px, 16vw, 100px);
        bottom: -1.5rem;
        right: -1rem;
    }

    /* Name badges */
    .mathAvatarName {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
    }

    #mathAvatarName { font-size: 1.3rem; }

    /* Info icons */
    .profileInfoIcon {
        width: 2.8rem;
        height: 2.8rem;
        background-size: 2.4rem;
    }

    /* Tooltips: centred over icon */
    #mathAvatarCaptainDesc,
    #mathAvatarShipDesc,
    #mathAvatarModeDesc {
        left: 50%;
        top: 110%;
        transform: translateX(-50%);
        width: 85vw;
        font-size: 0.85rem;
    }

    /* Skills */
    #mathSkillInfoWrapper {
        grid-template-columns: 1fr;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    #mathProfileMathGroupWrapperSection {
        grid-column: 1;
        max-height: 110px;
        padding: 6px;
    }

    .mathSkillInfoSkill {
        width: 62px;
        
    }

    .mathSkillInfoWinrate { font-size: 0.9rem; }

    .mathSkillInfoAnalysisSliderWrapper {
        grid-template-columns: 1.5fr 2fr 0.8fr;
        font-size: 0.78rem;
        gap: 0.3rem;
    }

    /* Cards: smaller, no zoom-on-hover */
    .skillTargetCard { max-width: 5.5rem; }

    .skillTargetCard:hover > :first-child,
    .libraryCardWrapper:hover > :first-child {
        transform: none;
    }

    /* Card desc: fixed centre overlay on touch */
    .profileCardDesc {
        position: fixed;
        width: 80vw;
        max-width: 280px;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        font-size: 0.75rem;
        padding: 0.75rem;
        z-index: 100;
    }

    /* Card action buttons */
    #cardActionsWrapper > button {
        font-size: 0.85rem;
        padding: 0.3rem 0.5rem;
    }

    /* Close button */
    #mathSkillInfoCloseBtn {
        font-size: 1.5rem;
        top: 6px;
        right: 6px;
    }

    /* Card library */
    #cardLibrary {
        top: 10%;
        max-height: 80vh;
        overflow-y: auto;
        padding: 0.6rem;
    }

    #cardLibraryInnerWrapper { gap: 0.5rem; }

    .libraryCardWrapper { width: 5rem; }

    #mathProfileMathGroupWrapper .mathGroupListTitle { font-size: 0.9rem; }
}

/* ── Extra small (< 380px) ────────────────────────────────── */
@media (max-width: 380px) {
    .mathSkillInfoSkill {
        width: 52px;
        
    }

    .skillTargetCard { max-width: 4.5rem; }

    #mathAvatarWrapper { width: clamp(140px, 50vw, 200px); }

    .captainChangerButton {
        width: 18px;
        height: 18px;
    }
}
