:root {
    --primary-pink: #FF69B4;
    --primary-gradient: linear-gradient(135deg, #FF69B4 0%, #FFB6C1 100%);
    --winner-color: #4CAF50;
    --loser-color: #9E9E9E;
    --text-dark: #333;
    --radius-md: 12px;
    --radius-xl: 24px;
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
    
    /* [수정] 기둥 간격 정의 - JS와 시각적 일치를 위해 중요 */
    --column-width: 120px; 
}

/* 폭죽 애니메이션 */
.firework {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    animation: firework-burst 0.8s ease-out forwards;
}

@keyframes firework-burst {
    0% { transform: scale(0); opacity: 1; }
    100% { transform: scale(5); opacity: 0; }
}

/* 컨테이너 */
.ladder-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px 80px;
    padding-bottom: calc(50px + 20px); /* 스크롤버튼 + 띠배너1번 + 고정배너 + 여백 */
    font-family: 'Pretendard', sans-serif;
    min-height: 100vh;
}

/* 설정 카드 */
.setup-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    margin: 0 auto;
}

.form-group { 
    margin-bottom: 20px; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
}

.form-group input { 
    padding: 15px; 
    border: 2px solid #eee; 
    border-radius: var(--radius-md); 
    font-size: 16px; 
}

.start-btn, .reset-btn {
    width: 100%; padding: 18px; background: var(--primary-gradient);
    color: white; border: none; border-radius: var(--radius-md);
    font-size: 18px; font-weight: 700; cursor: pointer; transition: 0.3s;
}

.start-btn:hover { 
    transform: translateY(-3px); 
    box-shadow: 0 5px 15px rgba(255,105,180,0.4); 
}

/* 사다리 게임판 */
.ladder-area {
    background: white; 
    border-radius: var(--radius-xl); 
    padding: 60px 20px;
    box-shadow: var(--shadow-lg); 
    margin: 30px 0; 
    overflow-x: auto;
}

.ladder-wrapper { 
    display: flex; 
    justify-content: center; 
    min-width: fit-content; 
    margin: 0 auto;
}

.ladder-column { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    width: var(--column-width); /* 기둥 너비 고정 */
    position: relative;
}

.player-name {
    padding: 10px 15px; 
    background: #f8f9fa; 
    border-radius: 8px;
    font-weight: 700; 
    margin-bottom: 25px; 
    font-size: 14px;
    width: 80%;
    text-align: center;
    border: 1px solid #eee;
}

/* 세로선 */
.ladder-line { 
    width: 4px; 
    background: #444; 
    height: 400px; 
    position: relative; 
    overflow: visible; /* [중요] 가로줄이 밖으로 보여야 함 */
}

/* [중요] 가로줄(Rung) 스타일 수정 */
.ladder-rung {
    position: absolute; 
    height: 4px; 
    background: #444; 
    z-index: 1;
}

/* 오른쪽으로 뻗는 줄: 현재 기둥 중심에서 다음 기둥 중심까지 */
.ladder-rung.right { 
    left: 0;
    width: var(--column-width); 
}

/* 왼쪽으로 뻗는 줄: 이전 기둥에서 오는 줄 (시각적 중복 방지를 위해 선택적 표시) */
.ladder-rung.left { 
    right: 0;
    width: var(--column-width);
    display: none; /* right 줄이 다음 기둥까지 닿으므로 left는 숨겨도 무방 */
}

/* 애니메이션 포인트 */
.animation-point {
    position: absolute; 
    width: 16px; 
    height: 16px; 
    background: var(--primary-pink);
    border-radius: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px var(--primary-pink); 
    z-index: 10;
}

/* 결과 박스 */
.result-box {
    margin-top: 25px; 
    padding: 12px; 
    background: #f1f3f5; 
    border-radius: 8px;
    width: 70px; 
    text-align: center; 
    font-weight: 700; 
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #495057;
}

.result-box.winner { 
    background: var(--winner-color); 
    color: white; 
    transform: scale(1.1); 
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.result-box.loser { 
    background: #dee2e6; 
    color: #adb5bd; 
}

/* 결과 리스트 영역 */
.result-area { 
    background: white; 
    border-radius: var(--radius-xl); 
    padding: 30px; 
    box-shadow: var(--shadow-lg); 
}

.result-list { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px; 
    margin-top: 20px; 
}

.result-item {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 15px;
    background: #f9f9f9; 
    border-radius: var(--radius-md); 
    opacity: 0.5;
    transition: 0.3s;
}

.result-item.revealed { opacity: 1; }

.result-item.winner { 
    border-left: 5px solid var(--winner-color); 
    background: #e8f5e9; 
}

.result-item-name { font-weight: 600; color: var(--text-dark); }
.result-item-status { font-weight: 800; }

.hidden { display: none; }

/* 반응형 */
@media (max-width: 768px) {
    :root { --column-width: 80px; }
    .ladder-column { width: var(--column-width); }
    .ladder-line { height: 320px; }
    .player-name { font-size: 12px; padding: 8px; }
    .result-box { width: 55px; font-size: 12px; }
    .ladder-container {
        padding: 20px 16px 80px;
        padding-bottom: calc(50px + 20px); /* 스크롤버튼 + 띠배너1번 + 띠배너여백 + 고정배너 + 여백 */
    }
}