/* === MODE SELECTION & CAMPAIGN UI === */
#mode-select-overlay,
#chapter-select-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 9999 !important;
    /* Forced Z-Index */

    /* display state is handled by JS removing .hidden class */
    display: flex !important;
    visibility: visible !important;
    justify-content: center;
    align-items: flex-end;
    /* Mode select slides from bottom */

    opacity: 1 !important;
    transition: opacity 0.3s ease;
}

/* Force override global .hidden */
#mode-select-overlay.hidden,
#chapter-select-overlay.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

#chapter-select-overlay {
    align-items: center;
    /* Chapter select is centered modal */
}

/* Mode Select Panel */
.mode-panel {
    width: 100%;
    max-width: 500px;
    background: linear-gradient(180deg, rgba(20, 20, 30, 0.95) 0%, rgba(10, 10, 15, 1) 100%);
    border-top: 1px solid rgba(0, 229, 255, 0.3);
    border-radius: 20px 20px 0 0;
    padding: 30px 20px 50px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    /* Smooth iOS-like ease */
}

.mode-panel.slide-up {
    transform: translateY(0);
}

.mode-title {
    text-align: center;
    font-size: 1.5rem;
    color: #fff;
    margin-bottom: 25px;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    font-weight: 900;
}

.mode-options {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.mode-card {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    /* Rounder corners */
    padding: 25px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.mode-card:active {
    transform: scale(0.96);
}

.mode-card.campaign {
    border-color: rgba(170, 0, 255, 0.3);
    background: linear-gradient(135deg, rgba(50, 0, 100, 0.4) 0%, rgba(0, 0, 0, 0) 100%);
}

.mode-card.arcade {
    border-color: rgba(0, 229, 255, 0.3);
    background: linear-gradient(135deg, rgba(0, 50, 100, 0.4) 0%, rgba(0, 0, 0, 0) 100%);
}

.mode-icon {
    font-size: 3.5rem;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
    transition: transform 0.3s;
}

.mode-card:active .mode-icon {
    transform: scale(1.1);
}

.mode-info h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #fff;
    font-weight: 800;
    letter-spacing: 1px;
}

.mode-info p {
    margin: 5px 0 0;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Close/Back Buttons */
.mode-close-btn,
.chapter-close-btn {
    width: 100%;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    font-family: inherit;
    font-weight: 800;
    border-radius: 12px;
    margin-top: 15px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.mode-close-btn:active,
.chapter-close-btn:active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Chapter Select Modal */
.chapter-content {
    background: #111;
    width: 85%;
    max-width: 380px;
    padding: 30px 20px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
    max-height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* User Combat Power Header */
.user-power-header {
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid rgba(0, 229, 255, 0.3);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.1);
}

.power-label {
    display: block;
    font-size: 0.65rem;
    color: rgba(0, 229, 255, 0.8);
    font-weight: 900;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.power-value {
    font-size: 1.6rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    font-family: 'Outfit';
}

.chapter-header {
    text-align: center;
    color: #00e5ff;
    margin-top: 0;
    margin-bottom: 25px;
    letter-spacing: 2px;
    font-size: 1.4rem;
    text-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.chapter-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    transition: all 0.2s;
    text-align: left;
}

.chapter-card.unlocked {
    border-color: #00ff41;
    background: linear-gradient(90deg, rgba(0, 255, 65, 0.08) 0%, rgba(0, 0, 0, 0) 100%);
    cursor: pointer;
}

.chapter-card.unlocked:active {
    transform: scale(0.98);
    background: rgba(0, 255, 65, 0.15);
}

.chapter-card.locked {
    opacity: 0.4;
    filter: grayscale(1);
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.3);
}

.chapter-num {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 900;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.chapter-title {
    font-size: 1.3rem;
    font-weight: 900;
    margin-bottom: 6px;
    color: #fff;
    letter-spacing: 0.5px;
}

.chapter-desc {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 10px;
    line-height: 1.4;
}

.chapter-status {
    font-size: 0.7rem;
    font-weight: 900;
    color: #00ff41;
    /* Green for recommended */
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid rgba(0, 255, 65, 0.3);
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(0, 255, 65, 0.1);
}

.chapter-card.locked .chapter-status {
    color: #ff5555;
    border-color: rgba(255, 85, 85, 0.3);
    background: rgba(255, 85, 85, 0.1);
}