/* --- Party Management Screen (Single Screen) --- */

.party-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding-bottom: 80px;
    /* Space for navbar */
    gap: 10px;
}

/* Formation Section (Top) */
.formation-section {
    flex: 0 0 auto;
}

.formation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 5px;
}

.party-power {
    font-size: 12px;
    font-family: 'Cinzel', serif;
    color: var(--text-muted);
}

.formation-grid {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.formation-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.formation-label {
    font-size: 8px;
    color: var(--text-dim);
    letter-spacing: 0.1em;
}

.slot-wrapper {
    width: 80px;
    height: 80px;
    position: relative;
    /* Fixed constraint to prevent layout shift */
    flex: 0 0 80px;
}

.party-slot {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: absolute;
    /* Absolute within wrapper */
    top: 0;
    left: 0;
    overflow: visible;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
    z-index: 1;
    /* Base z-index */
}

.party-slot:hover {
    z-index: 10;
    /* Pop up on hover/selection if needed */
}

.party-slot.selected-slot {
    border: 2px solid var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
    background: rgba(59, 130, 246, 0.1);
}

.party-slot.empty {
    color: var(--text-dim);
    flex-direction: column;
    gap: 5px;
}

.party-slot.filled {
    background: var(--bg-panel);
    border-style: solid;
}

/* Image acts as background */
.party-slot img.slot-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

/* Text Overlay Styling */
.slot-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    padding: 2px 0;
    text-align: center;
    pointer-events: none;
    z-index: 10;
}

.slot-name {
    font-size: 9px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 2px;
    text-shadow: 0 1px 2px #000;
}

.slot-indicator {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--primary);
    font-size: 12px;
    animation: bounce 1s infinite;
    text-shadow: 0 0 5px var(--primary);
    z-index: 20;
}

@keyframes bounce {

    0%,
    100% {
        transform: translate(-50%, 0);
    }

    50% {
        transform: translate(-50%, -3px);
    }
}

/* Instruction Text */
.party-instruction {
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 5px;
    border-radius: 4px;
}

/* Roster Section (Bottom) */
.roster-section {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 10px;
    border-radius: var(--radius-md);
}

.roster-grid-large {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    overflow-y: auto;
    padding: 5px;
    scrollbar-width: thin;
}

.roster-card-large {
    aspect-ratio: 1;
    background: var(--bg-panel);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.1s;
    user-select: none;
    /* PREVENT TEXT SELECTION/DRAG */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.roster-card-large:active {
    transform: scale(0.95);
}

.roster-card-large.in-party {
    filter: grayscale(0.5) brightness(0.7);
    border-color: var(--gold);
}

.roster-card-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    pointer-events: none;
    /* Ensure clicks pass through to card or are handled by card events */
}

.party-badge {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: var(--gold);
    color: #000;
    font-size: 8px;
    font-weight: bold;
    text-align: center;
    padding: 2px 0;
    z-index: 20;
}

.roster-name {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    color: #fff;
    font-size: 10px;
    text-align: center;
    padding: 2px 0;
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.in-party .roster-name {
    bottom: 15px;
    /* Move up to make room for badge */
}

/* --- Modal & Animations --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s;
}

.modal-content {
    background: #1a1c29;
    background: linear-gradient(135deg, rgba(26, 28, 41, 0.98), rgba(13, 14, 20, 0.99));
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    width: 95%;
    /* Mobile optimized */
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-header {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-family: 'Cinzel', serif;
    font-size: 16px;
    color: var(--gold);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}


/* --- Character Detail Modal Specifics --- */

.char-top-header {
    margin-bottom: 15px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.char-fullname-display {
    font-family: 'Cinzel', serif;
    font-size: 20px;
    color: var(--text-main);
    text-shadow: 0 0 5px var(--primary-glow);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: bold;
}

.char-job-display {
    font-size: 12px;
    color: var(--gold);
    margin-top: 2px;
}

.char-detail-layout {
    display: flex;
    gap: 15px;
}

.char-detail-visual {
    flex: 0 0 58%;
    aspect-ratio: 2/3;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1), transparent);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.char-full-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
}

.char-detail-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-grid-detail {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border-radius: var(--radius-sm);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
    padding: 2px 0;
}

.modal-footer-note {
    margin-top: auto;
    text-align: center;
    font-size: 9px;
    color: var(--text-dim);
    padding-top: 10px;
}

/* --- Sortie Button --- */
.sortie-btn {
    background: linear-gradient(135deg, var(--danger), #b91c1c);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 40px;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    font-size: 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.4);
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sortie-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(220, 38, 38, 0.6);
}

.sortie-btn:active {
    transform: translateY(1px);
}

.sortie-btn.disabled {
    background: #333;
    color: #666;
    pointer-events: none;
    box-shadow: none;
}