/* css/layout.css */
header {
    width: 100%;
    height: 40px;
    position: fixed;
    top: 0;
    left: 0;
    background-color: #333;
    color: white;
    text-align: center;
    padding: 5px 0;
    font-size: 10px;
    box-shadow: 0px -2px 5px rgba(0, 0, 0, 0.1);
    font-size: 1.0rem;
    margin: 0px;
}


header a {
    color: #a5a5a5;
    text-decoration: none;
    transition: color 0.3s ease;
    font-size: 1.0rem;
}


.main-container {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1550px;
    min-width: 1200px;
    background-color: #f8f8f8;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    padding: 20px;
    flex-wrap: wrap;
    margin-top: 0px;
    box-sizing: border-box;
    max-height: 865px;
    overflow: auto;
}

.panel {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
}

.setup-panel {
    flex: 1 1 150px; /* 왼쪽 패널: 성장, 축소, 기본 너비 */
    min-width: 150px;
}

.game-panel {
    flex: 2 1 600px; /* 가운데 패널: 게임 화면이 가장 넓게 */
    min-width: 320px; /* 최소 너비 설정 */
    align-items: center; /* 게임 컨테이너를 중앙 정렬 */
    justify-content: flex-start;
}
.game-panel #game-container {
    /* margin-top: 15px;  */
}


.results-panel {
    flex: 1 1 150px; /* 오른쪽 패널: 성장, 축소, 기본 너비 */
    min-width: 150px;
}

/* Panel Titles */
.panel-title {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e0e0e0;
}

/* Setup Area Layout */
.setup-area-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* input-group, button 등의 세로 간격 */
    margin-bottom: 0.7rem;
}

.ball-names-container {
    display: flex;
    flex-direction: column;
    /* gap: 0.5rem; */
    margin-top: 0.5rem;
    height: 215px;
    min-height: 180px;
    max-height: 220px;
    overflow: auto;
}

.ranking-criteria-options,
.group-options-area {
    border-top: 1px dashed #e0e0e0;
    padding-top: 1rem;
    margin-top: 0.5rem;
}

/* Radio Button Group Layout */
.radio-group {
    display: flex;
    gap: 5px;
    margin-top: 0.5rem;
}

.radio-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: #555;
    cursor: pointer;
}

/* Control Buttons Group */
.control-buttons-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.control-buttons-group:last-of-type {
    margin-bottom: 15px; /* 마지막 버튼 그룹 아래 여백 */
}

/* Leaderboard Area */
.leaderboard-area {
    margin-bottom: 0px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    max-height: 470px;
    min-height: 250px;
    overflow: auto;
    height: 470px;
}

.leaderboard-area h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

#display-areas-container {
    display: flex;
    /* flex-direction: column; */
    justify-content: space-around;
    gap: 15px; /* 완료/실패/팀 영역 간 간격 */
    margin-top: 20px;
    width: 100%;
}

/* Ball Display Areas */
.ball-display-area {
    min-height: 80px; /* 최소 높이 증가 */
    background-color: #e3f2fd; /* 기본 밝은 파랑 */
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start; /* 상단부터 공 배치 */
    gap: 5px; /* 공들 사이 간격 */
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
    overflow-x: auto; /* 내용이 넘칠 경우 스크롤바 */
    border: 1px solid #b3e5fc;
    flex-grow: 1;
}

.ball-display-title {
    width: 100%; /* 제목이 한 줄 전체 차지 */
    font-size: 0.8rem;
    color: #555;
    font-style: normal; /* italic 제거 */
    padding: 0 5px 5px 0; /* 패딩 조정 */
    border-bottom: 1px solid rgba(0,0,0,0.1); /* 제목 아래 구분선 */
    margin-bottom: 5px;
}

.general-finished {
    background-color: #e8f5e9; /* 밝은 녹색 */
    border-color: #c8e6c9;
}
.general-finished .ball-display-title {
    color: #4CAF50; /* 녹색 글씨 */
}

.general-failed {
    background-color: #ffebee; /* 밝은 빨강 */
    border-color: #ffcdd2;
}
.general-failed .ball-display-title {
    color: #F44336; /* 빨간색 글씨 */
}

.team-display-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.team-specific-display {
    border: 1px solid #cfd8dc; /* 팀 영역 테두리 */
    border-radius: 8px;
    padding: 10px;
    background-color: #eceff1; /* 팀 영역 배경색 */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.team-specific-display .team-finished-area {
    margin-top: 10px;
    background-color: #f3f3f3; /* 팀 내부 완료 영역 배경색 */
    border-color: #dcdcdc; /* 팀 내부 완료 영역 테두리 */
}

.team-title {
    text-align: left; /* 팀 이름은 왼쪽 정렬 */
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-bottom: 0.2rem;
    border-bottom: 2px solid; /* 색상은 JS에서 동적으로 설정 */
    color: inherit; /* 상속받은 색상 사용 */
}


/* Recent Results Area */
.recent-results-area {
    margin-top: 10px;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    height: 200px;
    overflow: auto;
}

.recent-results-area h3 {
    margin-bottom: 1rem;
    color: #4a4a4a;
}

.recent-results-list {
    display: flex;
    flex-direction: column;
    gap: 10px; /* 결과 항목 간 간격 */
}

.recent-result-item {
    background-color: #ffffff;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
    border: 1px solid #e0e0e0;
}

.recent-result-item strong {
    color: #333;
    font-weight: 600;
}

.no-results-message {
    color: #888;
    text-align: center;
    padding: 15px;
    font-style: italic;
}



footer {
    width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
    background-color: #333;
    color: white;
    text-align: center;
    padding: 5px 0;
    font-size: 10px;
    box-shadow: 0px -2px 5px rgba(0, 0, 0, 0.1);
    z-index: 25;
}


footer a {
    color: #a5a5a5;
    text-decoration: none;
    transition: color 0.3s ease;
}



/* Responsive adjustments */
@media (max-width: 992px) {
    .main-container {
        flex-direction: column; /* 중간 화면부터 세로로 쌓이도록 */
        align-items: center;
        padding: 15px;
    }
    .panel {
        width: 100%;
        max-width: 600px; /* 가운데 정렬을 위해 최대 너비 설정 */
        margin-bottom: 20px;
    }
    .panel:last-child {
        margin-bottom: 0;
    }
}

@media (max-width: 640px) { /* sm breakpoint (모바일) */
    body {
        padding: 10px;
    }

    .main-container {
        padding: 10px;
        gap: 15px;
        min-width: 100%;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        max-height: 3000px;
    }

    .panel {
        padding: 15px;
    }
    .setup-area-grid {
        gap: 0.8rem;
    }
    .control-buttons-group {
        flex-direction: column; /* 버튼 세로로 쌓이게 */
        gap: 8px;
    }
    .control-button.half-width {
        width: 100%; /* 모바일에서 반 너비 버튼도 꽉 채우기 */
    }
    h1 {
        font-size: 1.8rem;
    }
    h2 {
        font-size: 1.5rem;
    }
    h3 {
        font-size: 1.3rem;
    }
    label {
        font-size: 0.9rem;
    }
    input[type="number"],
    input[type="text"],
    select {
        font-size: 0.9rem;
        padding: 0.5rem 0.7rem;
    }
    .input-help-text {
        font-size: 0.7rem;
    }
    .ball-display-title {
        font-size: 0.75rem;
    }
}