/* 虛空裂隙・元素試煉・共鳴擂台 */
.side-mode-backdrop {
    position: fixed;
    inset: 0;
    z-index: 15000;
    display: flex;
    align-items: stretch;
    justify-content: center;
    background: rgba(2, 2, 10, 0.92);
    backdrop-filter: blur(12px);
    padding: 0;
    touch-action: auto;
    pointer-events: auto;
    -webkit-overflow-scrolling: touch;
}

.side-mode-backdrop.hidden {
    display: none !important;
}

.side-mode-modal {
    position: relative;
    width: min(98vw, 1680px);
    max-height: min(96dvh, 980px);
    height: 100%;
    height: min(96dvh, 980px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 22px;
    border: 1px solid rgba(126, 232, 255, 0.35);
    background: linear-gradient(165deg, rgba(10, 14, 32, 0.98), rgba(4, 6, 16, 0.99));
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    touch-action: auto;
    pointer-events: auto;
}

body.side-mode-modal-open #screen-app > .app-header,
body.side-mode-modal-open #screen-app > .side-nav,
body.side-mode-modal-open .void-global-footer,
body.side-mode-modal-open .void-chat-panel {
    pointer-events: none !important;
}

body.side-mode-modal-open .side-mode-backdrop {
    touch-action: auto;
}

.side-mode-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    padding: 1.15rem 1.35rem;
    border-bottom: 1px solid rgba(126, 232, 255, 0.2);
    text-align: center;
}

.side-mode-head > div:first-child {
    flex: 1 1 auto;
    width: 100%;
    padding: 0 2.75rem;
}

.side-mode-head__title {
    margin: 0 0 0.4rem;
    font-size: clamp(1.25rem, 2.2vw, 1.55rem);
    font-weight: 900;
    color: #e8f4ff;
    text-align: center;
}

.side-mode-head__sub {
    margin: 0;
    font-size: clamp(0.92rem, 1.4vw, 1.02rem);
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.72);
    text-align: center;
}

.side-mode-close {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2.75rem;
    height: 2.75rem;
    min-width: 44px;
    min-height: 44px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.05rem;
    cursor: pointer;
    z-index: 3;
    -webkit-tap-highlight-color: transparent;
}

.side-mode-body {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr) minmax(260px, 300px);
    gap: 1rem;
    padding: 1rem 1.35rem 1.35rem;
    overflow: hidden;
    min-height: 0;
}

.side-mode-main {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
    min-height: 0;
    position: relative;
    z-index: 2;
}

.side-mode-aside {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-height: 0;
    padding: 0.85rem 0.9rem;
    border-radius: 14px;
    border: 1px solid rgba(126, 232, 255, 0.2);
    background: rgba(0, 0, 0, 0.38);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.side-mode-aside--info {
    border-color: rgba(192, 132, 252, 0.28);
}

.side-mode-panel__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    color: #e8f4ff;
    text-align: center;
}

.side-mode-panel__sub {
    margin: 0;
    font-size: 0.84rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.58);
    text-align: center;
}

.side-mode-rank-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.sm-rank-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 0.45rem;
    align-items: center;
    padding: 0.55rem 0.6rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.88rem;
}

.sm-rank-row--you {
    border-color: rgba(255, 215, 0, 0.45);
    background: rgba(255, 215, 0, 0.1);
}

.sm-rank-num {
    font-family: Orbitron, 'Noto Sans TC', sans-serif;
    font-weight: 800;
    font-size: 0.92rem;
    color: #ffd56a;
    text-align: center;
}

.sm-rank-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 700;
}

.sm-rank-val {
    font-family: Orbitron, 'Noto Sans TC', sans-serif;
    font-size: 0.84rem;
    font-weight: 800;
    color: #7ee8ff;
    white-space: nowrap;
}

.sm-panel-empty {
    margin: 0.65rem 0 0;
    font-size: 0.9rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.48);
}

.side-mode-info-block {
    font-size: 0.92rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.84);
    overflow-y: auto;
    min-height: 0;
}

.side-mode-info-block--reward {
    padding-top: 0.55rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.side-mode-info-block h4 {
    margin: 0 0 0.45rem;
    font-size: 0.95rem;
    font-weight: 900;
    color: #c4b5fd;
    text-align: center;
}

.side-mode-info-block ul {
    margin: 0;
    padding-left: 1.15rem;
}

.side-mode-info-block li {
    margin-bottom: 0.35rem;
}

.side-mode-info-block li:last-child {
    margin-bottom: 0;
}

.side-mode-info-block .sm-info-meta {
    margin: 0.55rem 0 0;
    font-size: 0.84rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.58);
}

.side-mode-info-block .sm-info-tag {
    display: inline-block;
    margin-top: 0.45rem;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 800;
    color: #ffe8b8;
    background: rgba(255, 209, 102, 0.14);
    border: 1px solid rgba(255, 209, 102, 0.28);
}

.side-mode-roster {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 0.85rem;
    min-height: min(420px, 52vh);
    max-height: min(640px, 64vh);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.85rem;
    border-radius: 14px;
    border: 1px solid rgba(126, 232, 255, 0.22);
    background: rgba(0, 0, 0, 0.42);
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 960px) {
    .side-mode-backdrop {
        padding: 0;
        align-items: stretch;
    }

    .side-mode-modal {
        width: 100%;
        max-width: 100%;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
        border-left: none;
        border-right: none;
        min-height: 0;
    }

    .side-mode-head {
        flex-shrink: 0;
        padding:
            max(10px, env(safe-area-inset-top, 0px))
            max(10px, env(safe-area-inset-right, 0px))
            8px
            max(10px, env(safe-area-inset-left, 0px));
    }

    .side-mode-head > div:first-child {
        padding: 0 2.75rem 0 0;
        text-align: left;
    }

    .side-mode-head__title {
        font-size: 1.05rem;
        text-align: left;
    }

    .side-mode-head__sub {
        font-size: 0.82rem;
        text-align: left;
        line-height: 1.45;
    }

    .side-mode-close {
        right: max(10px, env(safe-area-inset-right, 0px));
        top: max(10px, env(safe-area-inset-top, 0px));
        transform: none;
    }

    .side-mode-body {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
        gap: 0.65rem;
        padding:
            0.5rem
            max(10px, env(safe-area-inset-right, 0px))
            max(12px, env(safe-area-inset-bottom, 0px))
            max(10px, env(safe-area-inset-left, 0px));
    }

    .side-mode-main {
        order: 1;
        flex: none;
        width: 100%;
        min-height: 0;
        gap: 0.5rem;
        display: flex;
        flex-direction: column;
    }

    .side-mode-main--picking .side-mode-log {
        display: none;
    }

    .side-mode-aside--info {
        order: 2;
        flex: none;
        width: 100%;
        max-height: none;
        padding: 0.65rem 0.75rem;
        overflow: visible;
    }

    .side-mode-aside--rank {
        order: 3;
        flex: none;
        width: 100%;
        max-height: none;
        padding: 0.65rem 0.75rem;
        overflow: visible;
    }

    .side-mode-rank-list {
        max-height: min(36vh, 260px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .side-mode-info-block {
        font-size: 0.76rem;
        line-height: 1.45;
    }

    .side-mode-info-block h4 {
        font-size: 0.82rem;
        margin-bottom: 0.25rem;
    }

    .side-mode-roster {
        flex: none;
        width: 100%;
        min-height: min(220px, 32vh);
        height: auto;
        max-height: min(50vh, 400px);
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: auto;
        gap: 0.55rem;
        padding: 0.55rem;
        overflow-y: auto;
        overflow-x: hidden;
        touch-action: pan-y;
        align-content: start;
        align-items: start;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
    }

    .side-mode-main--picking .side-mode-roster:not(.side-mode-roster--showcase) {
        max-height: min(54vh, 440px);
        min-height: min(260px, 38vh);
        touch-action: pan-y;
    }

    .sm-pick {
        display: block;
        min-height: 0;
        height: auto;
        width: 100%;
        aspect-ratio: 3 / 4;
        align-self: start;
        position: relative;
        z-index: 2;
        pointer-events: auto;
        -webkit-tap-highlight-color: transparent;
    }

    .sm-pick__name {
        font-size: 0.72rem;
        padding: 0.45rem 0.35rem 0.5rem;
    }

    .sm-pick__power {
        font-size: 0.8rem;
    }

    .side-mode-log {
        flex: 0 0 auto;
        width: 100%;
        max-height: min(32vh, 220px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .side-mode-body--picking {
        padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    }

    .side-mode-main--picking .side-mode-start {
        position: sticky;
        bottom: max(8px, env(safe-area-inset-bottom, 0px));
        z-index: 4;
        flex-shrink: 0;
        margin-top: 0.35rem;
        padding: 0.85rem 1rem;
        font-size: 1rem;
        letter-spacing: 0.06em;
        border: 2px solid rgba(126, 232, 255, 0.55);
        background: linear-gradient(135deg, #7ee8ff, #c084fc);
        box-shadow:
            0 0 24px rgba(126, 232, 255, 0.35),
            0 8px 28px rgba(0, 0, 0, 0.5);
    }

    .side-mode-main--picking .side-mode-start:disabled {
        background: linear-gradient(135deg, rgba(55, 75, 105, 0.95), rgba(45, 38, 82, 0.95));
        border-color: rgba(126, 232, 255, 0.35);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    }

    .side-mode-roster--showcase {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: auto;
        align-items: start;
        justify-items: stretch;
        gap: 0.65rem;
        padding: 0.65rem 0.55rem;
        min-height: min(320px, 52vh);
        max-height: min(58vh, 480px);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
    }

    .side-mode-roster--showcase .sm-pick {
        width: 100%;
        min-height: min(148px, 44vw);
        height: auto;
        aspect-ratio: 3 / 4;
        align-self: start;
    }

    .side-mode-roster--showcase .sm-pick:nth-child(3) {
        grid-column: 1 / -1;
        justify-self: center;
        width: calc(50% - 0.35rem);
        max-width: 220px;
    }

    .side-mode-roster--showcase .sm-pick__power {
        font-size: clamp(0.88rem, 3.6vw, 1.05rem);
        top: 0.55rem;
    }

    .side-mode-roster--showcase .sm-pick__name {
        font-size: clamp(0.82rem, 3.2vw, 0.96rem);
        line-height: 1.35;
        padding: 0.55rem 0.45rem 0.65rem;
        -webkit-line-clamp: 3;
    }

    .side-mode-roster--showcase .sm-pick--locked .sm-pick__shade {
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.82) 0%,
            rgba(0, 0, 0, 0.28) 40%,
            transparent 68%
        );
    }

    .side-mode-info-block {
        max-height: none;
        overflow: visible;
    }

    .side-mode-body--fighting {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }

    .side-mode-body--fighting .side-mode-aside--info {
        display: none;
    }

    .side-mode-main--fighting {
        grid-template-rows: minmax(0, 1fr);
        gap: 0;
    }

    .side-mode-main--fighting .side-mode-roster {
        display: none !important;
    }

    .side-mode-main--fighting .side-mode-start {
        display: none !important;
    }

    .side-mode-main--fighting .side-mode-log {
        display: block !important;
        flex: 1 1 auto;
        min-height: 0;
        height: 100%;
        max-height: none;
        margin: 0;
        padding: 0.65rem 0.75rem;
        font-size: 0.84rem;
        line-height: 1.55;
        border-radius: 12px;
    }

    .side-mode-body--fighting .side-mode-aside--rank {
        order: 2;
        max-height: none;
    }

    .side-mode-body--fighting .side-mode-aside--rank .side-mode-rank-list {
        max-height: min(28vh, 200px);
    }

    .side-mode-start,
    .side-mode-close,
    .sm-pick {
        touch-action: manipulation;
    }
}

@media (min-width: 961px) {
    .side-mode-roster:not(.side-mode-roster--showcase) {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .side-mode-roster--showcase {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        align-content: center;
        gap: 1.35rem 1.65rem;
        min-height: min(420px, 52vh);
        max-height: min(600px, 62vh);
    }

    .side-mode-roster--showcase .sm-pick {
        flex: 0 1 clamp(200px, 22vw, 280px);
        width: clamp(200px, 22vw, 280px);
        min-height: 280px;
    }

    .side-mode-roster--showcase .sm-pick__power {
        font-size: clamp(0.95rem, 1.4vw, 1.12rem);
    }

    .side-mode-roster--showcase .sm-pick__name {
        font-size: clamp(0.9rem, 1.3vw, 1.02rem);
        padding: 0.6rem 0.5rem 0.7rem;
    }
}

@media (min-width: 1500px) {
    .side-mode-roster:not(.side-mode-roster--showcase) {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.sm-pick {
    position: relative;
    aspect-ratio: 3 / 4;
    min-height: 200px;
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(8, 6, 20, 0.95);
    cursor: pointer;
    padding: 0;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-appearance: none;
    appearance: none;
    font: inherit;
}

@media (max-width: 960px) {
    .sm-pick {
        min-height: 0;
    }
}

.sm-pick:hover:not(.sm-pick--locked) {
    transform: translateY(-3px) translateZ(0);
    border-color: rgba(126, 232, 255, 0.55);
    box-shadow: 0 10px 28px rgba(80, 180, 255, 0.22);
}

.sm-pick--locked {
    cursor: default;
}

.sm-pick.is-selected {
    border-color: #00ffff;
    border-width: 3px;
    transform: scale(1.03) translateZ(0);
    box-shadow:
        0 0 0 4px rgba(0, 255, 255, 0.55),
        0 0 28px rgba(0, 255, 255, 0.45),
        0 12px 32px rgba(80, 180, 255, 0.35);
    z-index: 3;
}

.sm-pick.is-selected::before {
    content: '✓';
    position: absolute;
    top: 0.45rem;
    right: 0.45rem;
    z-index: 6;
    width: 1.65rem;
    height: 1.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 900;
    line-height: 1;
    color: #0a1020;
    background: linear-gradient(135deg, #7ee8ff, #00ffff);
    box-shadow: 0 0 14px rgba(0, 255, 255, 0.85);
    pointer-events: none;
}

.sm-pick.is-selected .sm-pick__shade {
    background: linear-gradient(
        to top,
        rgba(0, 80, 120, 0.92) 0%,
        rgba(0, 40, 80, 0.45) 42%,
        rgba(0, 255, 255, 0.12) 68%,
        transparent 100%
    );
}

.sm-pick__art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    image-rendering: auto;
}

.sm-pick__art--empty {
    background:
        radial-gradient(circle at 50% 35%, rgba(126, 232, 255, 0.12), transparent 55%),
        rgba(8, 6, 20, 0.95);
}

.sm-pick__shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.35) 38%, transparent 62%);
    pointer-events: none;
}

.sm-pick__power {
    position: absolute;
    top: 0.5rem;
    left: 0;
    right: 0;
    z-index: 2;
    text-align: center;
    font-family: Orbitron, 'Noto Sans TC', sans-serif;
    font-size: clamp(0.88rem, 1.8vw, 1.05rem);
    font-weight: 800;
    color: #ffe8b8;
    text-shadow:
        0 0 8px rgba(0, 0, 0, 0.95),
        0 2px 6px rgba(0, 0, 0, 0.9),
        0 0 12px rgba(255, 180, 80, 0.35);
    pointer-events: none;
}

.sm-pick__name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 0.55rem 0.45rem 0.6rem;
    font-size: clamp(0.82rem, 1.6vw, 0.95rem);
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95);
    pointer-events: none;
}

.sm-empty {
    grid-column: 1 / -1;
    margin: 0;
    text-align: center;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.55);
}

.side-mode-log {
    flex: 0 0 auto;
    min-height: 0;
    max-height: min(200px, 26vh);
    overflow-y: auto;
    padding: 0.75rem 0.85rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.4);
    font-size: 0.92rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.82);
}

.side-mode-log:empty {
    display: none;
    padding: 0;
    border: none;
    max-height: 0;
}

.side-mode-log p {
    margin: 0 0 0.3rem;
}

.side-mode-start {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    width: 100%;
    padding: 0.9rem 1.15rem;
    border: 2px solid rgba(126, 232, 255, 0.45);
    border-radius: 999px;
    font-size: 1.05rem;
    font-weight: 900;
    color: #0a1020;
    background: linear-gradient(135deg, #7ee8ff, #c084fc);
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
}

.side-mode-start:disabled {
    opacity: 1;
    cursor: not-allowed;
    color: rgba(232, 244, 255, 0.92);
    background: linear-gradient(135deg, rgba(50, 70, 100, 0.85), rgba(40, 36, 72, 0.9));
    border: 2px solid rgba(126, 232, 255, 0.28);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.side-mode-result {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.78);
    padding: 1rem;
}

.side-mode-result.hidden {
    display: none !important;
}

.side-mode-result__box {
    width: min(100%, 360px);
    padding: 1.5rem 1.15rem;
    border-radius: 18px;
    border: 1px solid rgba(255, 209, 102, 0.45);
    background: linear-gradient(165deg, rgba(20, 16, 40, 0.98), rgba(6, 4, 14, 0.98));
    text-align: center;
}

.side-mode-result__icon {
    font-size: 2.5rem;
    margin-bottom: 0.35rem;
}

.side-mode-result__title {
    margin: 0 0 0.45rem;
    font-size: 1.1rem;
    font-weight: 900;
    color: #fff8ec;
    text-align: center;
}

.side-mode-result__sub {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.75);
    white-space: pre-line;
}

.battle-mode-card--rift {
    border-color: rgba(126, 232, 255, 0.35);
}

.battle-mode-card--rift:hover {
    border-color: rgba(126, 232, 255, 0.6);
    box-shadow: 0 16px 42px rgba(80, 180, 255, 0.18);
}

.battle-mode-card--element {
    border-color: rgba(100, 220, 140, 0.35);
}

.battle-mode-card--element:hover {
    border-color: rgba(100, 220, 140, 0.6);
    box-shadow: 0 16px 42px rgba(80, 200, 120, 0.18);
}

.battle-mode-card--resonance {
    border-color: rgba(255, 120, 200, 0.35);
}

.battle-mode-card--resonance:hover {
    border-color: rgba(255, 120, 200, 0.6);
    box-shadow: 0 16px 42px rgba(200, 80, 180, 0.18);
}

@media (min-width: 1024px) {
    .battle-hub {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        max-width: 1200px;
    }
}
