body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a2e;
    color: #e0e0e0;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    color: #fca311;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    text-align: center;
}

.calculator-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    width: 100%;
    max-width: 1200px;
}

.side {
    background-color: #16213e;
    border: 2px solid #0f3460;
    border-radius: 10px;
    padding: 20px;
    width: 45%;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

h2 {
    margin-top: 0;
    color: #e94560;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 270px; /* 2*120px + 15px gap + 2*2px border */
    justify-content: center;
}

.item-slot {
    width: 120px;
    height: 120px;
    background-color: #0f3460;
    border: 2px dashed #537895;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
    position: relative;
    overflow: hidden;
    padding: 5px;
    box-sizing: border-box;
}

.item-slot:hover {
    background-color: #2a3e63;
    border-color: #fca311;
}

.item-slot .plus-sign {
    font-size: 48px;
    color: #c4c4c4;
    user-select: none;
}

.item-slot img {
    max-width: 90%;
    max-height: 70%;
    object-fit: contain;
}

.item-slot .item-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 3px 0;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-slot .remove-item {
    position: absolute;
    top: 3px;
    right: 3px;
    background-color: #e94560;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 14px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    display: none;
    z-index: 2;
    font-weight: bold;
}

.item-slot.has-item:hover .remove-item {
    display: block;
}

.total-value {
    background-color: #0f3460;
    padding: 10px 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 270px;
    text-align: center;
    margin-top: auto;
}

.total-value h3 {
    margin: 0;
    color: #fca311;
    font-size: 16px;
}

#you-total, #them-total {
    font-weight: bold;
    color: white;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #16213e;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #0f3460;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #0f3460;
}

.modal-header h3 {
    margin: 0;
    color: #fca311;
    font-size: 24px;
}

#close-modal {
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 30px;
    cursor: pointer;
    padding: 0 10px;
    line-height: 1;
}

#close-modal:hover {
    color: #e94560;
}

.item-list-grid {
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 15px;
    padding-right: 10px;
}

.modal-item {
    background-color: #0f3460;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    text-align: center;
}

.modal-item:hover {
    background-color: #2a3e63;
    transform: scale(1.05);
}

.modal-item img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.modal-item p {
    margin: 5px 0 0 0;
    font-size: 13px;
    font-weight: bold;
    color: #e0e0e0;
    line-height: 1.2;
    min-height: 2.4em; /* Ensures space for two lines */
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .side {
        width: 90%;
        min-width: unset;
    }
    h1 {
        font-size: 24px;
    }
}