/* two-choice-sorter custom CSS */
.sorter-container {
    max-width: 900px;
    margin: 20px auto;
    background: rgba(30, 41, 59, 0.8);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.box-title {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 20px;
    text-align: center;
    color: #fff;
}

.grid-2 {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
}
.grid-2 > div {
    flex: 1;
    min-width: 300px;
}

.input-box {
    width: 100%;
    height: 150px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px;
    color: #fff;
    margin-bottom: 10px;
    resize: vertical;
}

.item-list {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 15px;
    height: 250px;
    overflow-y: auto;
}

.btn-primary {
    display: inline-block;
    background: #3B82F6;
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    width: 100%;
    text-decoration: none;
    transition: background 0.2s;
}
.btn-primary:hover:not(:disabled) { background: #2563EB; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    display: inline-block;
    background: #EC4899;
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    width: 100%;
    margin-top: 15px;
}
.btn-secondary:hover:not(:disabled) { background: #DB2777; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-start {
    display: inline-block;
    background: #10B981;
    color: #fff;
    border: none;
    padding: 15px 40px;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 4px 15px rgba(16,185,129,0.4);
}
.btn-start:disabled { opacity: 0.5; cursor: not-allowed; }

.hidden { display: none !important; }

/* Battle UI */
.battle-area {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 20px;
    margin-top: 30px;
}
.choice-btn {
    flex: 1;
    min-height: 250px;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
}
.choice-btn:hover {
    transform: translateY(-5px);
    background: rgba(255,255,255,0.1);
    border-color: #3B82F6;
}
.choice-img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    margin-bottom: 15px;
    border-radius: 8px;
}
.choice-text {
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    word-break: break-all;
}

.vs-text {
    display: flex;
    align-items: center;
    font-size: 2.5rem;
    font-weight: 900;
    color: #ef4444;
    font-style: italic;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.progress-container {
    width: 100%;
    height: 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
    margin-bottom: 30px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: #3B82F6;
    width: 0%;
    transition: width 0.3s;
}

/* Items List */
.item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
}
.item-img-preview {
    width: 40px; height: 40px; object-fit: cover; border-radius: 4px; background:#fff;
}
.item-text-preview {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}
.item-delete {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-weight: bold;
}

/* Tier List Output */
.tier-board {
    background: #0f172a;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}
.tier-row {
    display: flex;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.05);
    min-height: 80px;
}
.tier-label {
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.5rem;
    color: #000;
    flex-shrink: 0;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.5);
}
.tier-content {
    flex-grow: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.1); border-left:none;
}
.tier-item {
    width: 70px;
    height: 70px;
    background: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    cursor: grab;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.tier-item:active { cursor: grabbing; }
.tier-item img {
    width: 100%; height: 100%; object-fit: cover;
}
.tier-item-text {
    font-size: 0.7rem;
    font-weight: bold;
    color: #fff;
    text-align: center;
    padding: 4px;
    word-break: break-all;
    line-height: 1.2;
}

.tier-item-rank-badge {
    position: absolute;
    top: -5px; right: -5px;
    background: #ef4444; color: #fff;
    font-size: 0.7rem; font-weight: bold;
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
    z-index: 10;
}

/* 📱 Mobile Responsiveness */
@media (max-width: 600px) {
    .sorter-container { padding: 15px; }
    .grid-2 { gap: 15px; }
    .grid-2 > div { min-width: 100%; }
    .battle-area { flex-direction: column; gap: 10px; }
    .choice-btn { min-height: 150px; padding: 15px; }
    .choice-text { font-size: 1.2rem; }
    .vs-text { font-size: 2rem; }
    .tier-board { padding: 10px; }
    .tier-label { width: 50px; font-size: 1.2rem; }
    .tier-item { width: 45px; height: 45px; }
    
    /* Ensure action buttons wrap properly */
    #step-2 > div[style*="gap:20px"] {
        flex-direction: column;
        gap: 10px !important;
    }
    
    #step-3 > div[style*="justify-content:space-between"] {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 15px;
    }
    #step-3 h2 { font-size: 1.5rem !important; }
}

/* Animations */
@keyframes popIn {
    0% { transform: scale(0.8) translateY(10px); opacity: 0; }
    80% { transform: scale(1.05) translateY(-2px); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes pulseVs {
    0% { transform: scale(1); text-shadow: 0 2px 10px rgba(239, 68, 68, 0.5); }
    50% { transform: scale(1.1); text-shadow: 0 4px 20px rgba(239, 68, 68, 0.8); }
    100% { transform: scale(1); text-shadow: 0 2px 10px rgba(239, 68, 68, 0.5); }
}

@keyframes hitWin {
    0% { transform: scale(1); filter: brightness(1); }
    40% { transform: scale(1.1); filter: brightness(1.2); box-shadow: 0 0 20px rgba(59, 130, 246, 0.5); }
    100% { transform: scale(1.05); filter: brightness(1.1); box-shadow: 0 0 15px rgba(59, 130, 246, 0.3); }
}

@keyframes hitLose {
    0% { transform: scale(1); filter: grayscale(0) opacity(1); }
    100% { transform: scale(0.9); filter: grayscale(1) opacity(0.5); }
}

@keyframes tieShake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
    100% { transform: translateX(0); }
}

.anim-pop-in {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.anim-pulse-vs {
    animation: pulseVs 1.5s infinite ease-in-out;
}

.anim-hit-win {
    animation: hitWin 0.3s ease-out forwards;
    border-color: #3B82F6 !important;
}

.anim-hit-lose {
    animation: hitLose 0.3s ease-out forwards;
    pointer-events: none;
}

.anim-tie-shake {
    animation: tieShake 0.3s ease-in-out forwards;
}
