/* 기본 스타일 초기화 및 body 설정 */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: sans-serif;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}
:root {
    --team-a-color: #f44336;
    --team-b-color: #2196f3;
}
*, *:before, *:after {
    box-sizing: inherit;
}

/* 두 팀을 감싸는 메인 컨테이너 */
.squad-container {
    display: flex;
    width: 100%;
    flex: 1; /* 남은 공간 모두 사용 */
    overflow: hidden; /* 스크롤바가 생기지 않도록 설정 */
}

/* 스코어보드 스타일 */
.scoreboard {
    background-color: white;
    height: 50px;
    display: flex;
    justify-content: center; /* 중앙 정렬 */
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 10;
    font-weight: bold;
    position: relative; /* 로고 절대 위치 배치를 위해 추가 */
}

/* [신규] 사이트 로고 스타일 */
.site-logo {
    position: absolute;
    left: 20px;
    height: 44px; /* 로고 크기 확대 (꽉 차게) */
    width: auto;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
}

/* [신규] 도움말 버튼 스타일 */
.help-btn {
    position: absolute;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
    z-index: 11;
}

.help-btn:hover { transform: scale(1.1); }

.team-color-bar {
    width: 6px;
    height: 100%;
    background-color: var(--team-a-color); /* 포인트 컬러 (A팀 색상 연동) */
}

#team-b-color-bar {
    background-color: var(--team-b-color);
}

.team-name {
    font-size: 1.2rem;
    color: black;
    padding: 0 10px;
    white-space: nowrap;
    cursor: pointer; /* 클릭 가능 표시 */
}

/* 팀 이름 래퍼 (메뉴 위치 기준) */
.team-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

/* [신규] 상단 팀 로고 스타일 */
.team-logo-header {
    height: 30px;
    display: none; /* 이미지가 있을 때만 스크립트로 block 처리 */
    object-fit: contain; /* 로고 비율 유지 및 중앙 정렬 */
}

#team-a-logo {
    margin-left: 15px;
    margin-right: 5px;
}

#team-b-logo {
    margin-left: 5px;
    margin-right: 15px;
}

/* 팀 설정 메뉴 */
.team-controls {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: white;
    border: 1px solid #ccc;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    flex-direction: column;
    z-index: 20;
    min-width: 90px;
}

.team-wrapper.show-controls .team-controls {
    display: flex;
}

.team-controls button {
    border: none;
    background: none;
    padding: 8px 10px;
    cursor: pointer;
    text-align: center;
    font-size: 0.9rem;
    width: 100%;
    white-space: nowrap;
}

.team-controls button:hover {
    background-color: #f0f0f0;
}

/* 색상 선택기 드롭다운 스타일 */
.color-picker-dropdown {
    display: none;
    width: 100%;
    height: 30px;
    cursor: pointer;
}

.score-box {
    background-color: black;
    color: white;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.score-input {
    width: 40px;
    height: 100%;
    font-size: 1.5rem;
    text-align: center;
    background-color: transparent;
    color: white;
    border: none;
    outline: none;
}
/* 입력창 화살표 제거 */
.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.timer-box {
    background-color: black;
    color: white;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 15px;
    font-family: monospace;
    font-size: 1.2rem;
    cursor: pointer; /* 클릭 가능 표시 */
    font-weight: bold; /* 글씨 굵게 */
}

.timer-part {
    background: transparent;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    width: 30px;
    text-align: center;
    outline: none;
    cursor: inherit;
}

.timer-part:not([readonly]) {
    cursor: text;
}

/* 타이머 래퍼 (메뉴 위치 기준) */
.timer-wrapper {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

/* 경기 진행 컨트롤 메뉴 */
.match-controls {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: white;
    border: 1px solid #ccc;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    flex-direction: column;
    z-index: 20;
    min-width: 60px;
}

.timer-wrapper.show-controls .match-controls {
    display: flex;
}

.match-controls button {
    border: none;
    background: none;
    padding: 8px 10px;
    cursor: pointer;
    text-align: center;
    font-weight: bold;
    font-size: 0.9rem;
    width: 100%;
    white-space: nowrap;
}

.match-controls button:hover {
    background-color: #f0f0f0;
}

/* 선수 목록 영역 (좌우 사이드) */
.player-list {
    flex: 1;
    background-color: #f5f5f5;
    padding: 20px;
    text-align: center;
    overflow-y: auto;
}

/* 목록 내부 섹션 구분 스타일 */
.list-section {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-bottom: 15px;
    padding: 10px;
}

.list-section h3 {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-section h3::after {
    content: '▼';
    font-size: 0.8em;
}

.list-section.collapsed h3::after {
    content: '▲';
}

.list-section.collapsed .player {
    display: none !important;
}

.count {
    font-size: 0.9rem;
    color: #666;
    font-weight: normal;
}

/* [신규] 포지션 필터 버튼 */
.filter-controls {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 10px;
}

.filter-btn {
    padding: 5px 10px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    transition: all 0.2s;
}

.filter-btn.active {
    background-color: #333;
    color: white;
    border-color: #333;
}

/* [신규] 스프레드시트 편집 버튼 스타일 */
.btn-edit-spreadsheet {
    background-color: #ff9800;
    color: white;
    border-color: #ff9800;
}

/* 포메이션 버튼 영역 */
.formation-controls {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 10px;
}

.formation-select {
    padding: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 3px;
    width: 100%;
}

/* 개별 선수 아이템 */
.player {
    display: flex;
    align-items: center;
    background-color: #fafafa;
    padding: 8px 12px;
    margin: 5px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: grab;
}

.player-number {
    font-weight: bold;
    color: #f44336;
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.player-pos {
    font-size: 0.75rem;
    font-weight: bold;
    width: 32px;
    text-align: center;
    margin-right: 8px;
    padding: 2px 0;
    border-radius: 3px;
    color: #fff;
    background-color: #9e9e9e;
}

/* 포지션별 색상 */
.player-pos[data-pos="GK"] { background-color: #ff9800; }
.player-pos[data-pos="DF"] { background-color: #2196f3; }
.player-pos[data-pos="MF"] { background-color: #4caf50; }
.player-pos[data-pos="FW"] { background-color: #f44336; }

/* 카드 스타일 */
.player-card {
    display: inline-block;
    width: 10px;
    height: 14px;
    margin-left: 5px;
    border-radius: 2px;
    border: 1px solid #ccc; /* 기본 테두리 */
    background-color: #fff; /* 기본 배경 (카드 없음) */
    opacity: 1;
}
.player-card.yellow { background-color: #ffeb3b; border: 1px solid #fbc02d; opacity: 1; }
.player-card.red { background-color: #f44336; border: 1px solid #d32f2f; opacity: 1; }

/* [신규] 부상 아이콘 스타일 */
.player-injury {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 5px;
    border-radius: 2px;
    border: 1px solid #ccc;
    background-color: #fff;
    cursor: pointer;
    position: relative; /* + 기호 위치 기준 */
    vertical-align: middle; /* 다른 아이콘과 정렬 */
}

.player-injury.injured {
    background-color: transparent;
    border-color: transparent;
}

.player-injury.injured::before {
    content: '+';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff0000; /* 선명한 빨간색 */
    font-weight: bold;
    font-size: 20px; /* 크기 확대 */
    line-height: 1;
}

.player-name {
    flex-grow: 1;
    display: flex;
    justify-content: flex-start; /* 아이콘들을 오른쪽으로 밀기 위해 변경 */
    align-items: center;
}

.player-icons {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
}

/* 교체 표시 스타일 */
.player-sub {
    display: none;
    font-size: 0.8em;
    font-weight: bold;
    margin-right: 5px;
}
.player-sub.in { display: inline-block; color: #4caf50; } /* Green */
.player-sub.in::after { content: '▲'; }
.player-sub.out { display: inline-block; color: #f44336; } /* Red */
.player-sub.out::after { content: '▼'; }

/* 유니폼 모드에서 교체 표시 위치 조정 */
.team .player .player-sub {
    display: none; /* 유니폼 모드에서는 일단 숨김 (필요시 표시 가능) */
}

/* 드래그 중인 선수 아이템 */
.player.dragging {
    opacity: 0.5;
    background: #cce5ff;
}

/* [신규] 필드와 감독 정보를 감싸는 래퍼 */
.field-wrapper {
    flex: 2;
    display: flex;
    flex-direction: column;
    margin: 4% 0;
    position: relative;
}

/* 각 팀 영역의 공통 스타일 */
.team {
    flex: 1; /* 래퍼 내부에서 남은 공간 차지 */
    padding: 20px;
    text-align: center;
    position: relative; /* 포메이션 배치를 위해 자식 요소의 기준점 설정 */
    overflow: hidden; /* 선수가 영역 밖으로 나가는 것 방지 */
    border: 2px solid white; /* 경기장 외곽선 */
}

/* 유니폼 스타일 (경기장 위에 있을 때) */
.team .player {
    position: absolute; /* 필드 내 절대 위치 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    padding: 0;
    width: 60px; /* 유니폼 폭 */
    box-shadow: none;
    z-index: 5; /* 라인보다 위에 표시 */
}

/* 유니폼 모드에서 카드 위치 조정 */
.team .player .player-card {
    position: static;
    display: none;
    width: 10px;
    height: 14px;
    margin-left: 4px;
    border: none;
    vertical-align: middle;
}

.team .player .player-card.yellow,
.team .player .player-card.red {
    display: inline-block;
}

/* [신규] 유니폼 모드 부상 아이콘 */
.team .player .player-injury {
    display: none; /* 기본 숨김 */
    width: 14px;
    height: 14px;
    margin-left: 4px;
    border: none;
    vertical-align: middle;
}

.team .player .player-injury.injured {
    display: inline-block; /* 부상 시 표시 */
}

/* 유니폼 모드에서는 포지션 배지 숨김 */
.team .player .player-pos {
    display: none;
}

/* 유니폼 상의 (등번호 부분) */
.team .player .player-number {
    width: 50px;
    height: 40px;
    margin-right: 0;
    margin-bottom: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    /* 티셔츠 모양 만들기 (폴리곤) */
    clip-path: polygon(15% 0%, 85% 0%, 100% 25%, 85% 35%, 85% 100%, 15% 100%, 15% 35%, 0% 25%);
    /* 그림자 효과 (clip-path 사용 시 box-shadow 대신 filter 사용) */
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}

/* A팀 유니폼 색상 (빨강) */
.team[data-team="a"] .player .player-number {
    background-color: var(--team-a-color);
}

/* B팀 유니폼 색상 (파랑) */
.team[data-team="b"] .player .player-number {
    background-color: var(--team-b-color);
}

/* 선수 이름 (유니폼 아래) */
.team .player .player-name {
    color: white;
    text-shadow: 1px 1px 2px black;
    font-size: 0.85rem;
    font-weight: bold;
    background-color: rgba(0,0,0,0.4);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    display: inline-block;
}

/* A팀 필드 (왼쪽 진영) */
#team-a {
    background-color: #4CAF50;
    /* 잔디 패턴 + 골 라인 (왼쪽 40px 지점) */
    background-image: 
        linear-gradient(to right, transparent 40px, rgba(255, 255, 255, 0.7) 40px, rgba(255, 255, 255, 0.7) 43px, transparent 43px),
        repeating-linear-gradient(to right, #4CAF50, #4CAF50 50px, #43A047 50px, #43A047 100px);
    border-right: 1px solid rgba(255, 255, 255, 0.7); /* 하프라인 */
}

/* A팀 센터 서클 (반원) */
#team-a::before {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    border: 3px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    top: 50%;
    right: 0;
    transform: translate(50%, -50%); /* 오른쪽으로 절반 이동 */
    pointer-events: none; /* 드래그 방해 금지 */
}

/* A팀 페널티 박스 */
#team-a::after {
    content: '';
    position: absolute;
    width: 15%;
    height: 40%;
    border: 3px solid rgba(255, 255, 255, 0.7);
    top: 50%;
    left: 40px; /* 골 라인에 맞춰 이동 */
    transform: translateY(-50%);
    pointer-events: none;
}

/* B팀 필드 (오른쪽 진영) */
#team-b {
    background-color: #4CAF50;
    /* 잔디 패턴 + 골 라인 (오른쪽 40px 지점) */
    background-image: 
        linear-gradient(to left, transparent 40px, rgba(255, 255, 255, 0.7) 40px, rgba(255, 255, 255, 0.7) 43px, transparent 43px),
        repeating-linear-gradient(to right, #4CAF50, #4CAF50 50px, #43A047 50px, #43A047 100px);
    border-left: 1px solid rgba(255, 255, 255, 0.7); /* 하프라인 */
}

/* B팀 센터 서클 (반원) */
#team-b::before {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    border: 3px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%); /* 왼쪽으로 절반 이동 */
    pointer-events: none;
}

/* B팀 페널티 박스 */
#team-b::after {
    content: '';
    position: absolute;
    width: 15%;
    height: 40%;
    border: 3px solid rgba(255, 255, 255, 0.7);
    top: 50%;
    right: 40px; /* 골 라인에 맞춰 이동 */
    transform: translateY(-50%);
    pointer-events: none;
}

/* 경계선 스타일 */
#list-left { border-right: 1px solid #ddd; }
#list-right { border-left: 1px solid #ddd; }

/* 감독 표시 스타일 */
.manager-box {
    margin-top: 10px;
    background-color: #333; /* 배경색 조금 더 진하게 */
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 10;
    cursor: pointer;
    width: fit-content;
}
#manager-box-a {
    align-self: flex-start; /* 왼쪽 정렬 */
}
#manager-box-b {
    align-self: flex-end; /* 오른쪽 정렬 */
}
.manager-label {
    font-weight: bold;
    color: #ffd700;
}

/* D-DAY 바 스타일 */
.d-day-bar {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 8px 0;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    gap: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 9;
}

#d-day-count {
    font-weight: bold;
    color: #ffd700; /* 금색 강조 */
}

/* [신규] 팀 검색 모달 스타일 */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; /* z-index 상향 조정 */
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.6); /* 배경 더 어둡게 */
    backdrop-filter: blur(4px); /* 배경 블러 효과 */
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background-color: #fff;
    margin: 5% auto; /* 상단 여백 조정 */
    padding: 0; /* 내부 패딩 제거 (헤더/바디 분리) */
    border: none;
    width: 90%; 
    max-width: 800px; /* [변경] 그리드 뷰를 위해 너비 확대 */
    border-radius: 12px; /* 둥근 모서리 */
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 85vh; /* 최대 높이 제한 */
    animation: slideDown 0.3s ease-out;
}

/* 모달 헤더 */
.modal-header {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
}

.close-modal {
    color: #999;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-modal:hover { color: #333; }

/* 모달 본문 */
.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.search-control-group {
    margin-bottom: 20px;
}

.search-control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    color: #333;
}

.search-select {
    width: 100%;
    padding: 12px 10px;
    font-size: 0.95rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
    background-color: white;
    cursor: pointer;
}

.search-input-group {
    display: flex;
}

#team-search-input {
    flex: 1;
    padding: 12px 15px;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px 0 0 8px;
    border-right: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#team-search-input:focus {
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

#btn-search-confirm {
    padding: 0 20px;
    background-color: #2196f3;
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

#btn-search-confirm:hover {
    background-color: #1976d2;
}

/* [신규] 보기 방식 토글 버튼 */
.view-toggle-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.view-btn {
    padding: 6px 10px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    margin-left: -1px; /* 버튼 연결 효과 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-btn svg {
    width: 20px;
    height: 20px;
    fill: #666;
}

.view-btn:first-child { border-radius: 4px 0 0 4px; }
.view-btn:last-child { border-radius: 0 4px 4px 0; }

.view-btn.active {
    background: #333;
    color: white;
    border-color: #333;
    z-index: 1;
}

.view-btn.active svg {
    fill: white;
}

/* [신규] 줌 컨트롤 스타일 */
#tournament-zoom-controls .view-btn {
    height: 30px; /* 높이 고정 */
}

#search-results {
    /* max-height 제거 (modal-body 스크롤 이용) */
    border-top: none;
    padding-top: 10px;
}

/* [신규] 바둑판형 스타일 (기본) */
#search-results.grid-view {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5열 배치 */
    gap: 10px;
}

/* 바둑판형일 때 순위 정보 표시 (상세 스탯은 제외) */
#search-results.grid-view .team-standing,
#search-results.group-view .team-standing { /* [수정] 그룹형도 중앙 정렬 */
    display: flex;
    justify-content: center;
    width: 100%;
}

#search-results.grid-view .standing-stats,
#search-results.group-view .standing-stats { /* [수정] 그룹형도 상세 스탯 숨김 (헤더에 표시하므로) */
    display: none;
}

/* [신규] 리스트형 스타일 */
#search-results.list-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#search-results.list-view .search-result-item {
    /* [변경] 리스트형 그리드 레이아웃 적용 */
    display: grid;
    grid-template-columns: 60px 1fr; /* 로고 영역(60px) | 정보 영역(나머지) */
    gap: 15px;
    align-items: center;
    text-align: left;
    padding: 10px 15px;
}

#search-results.list-view .team-logo {
    width: 50px;
    height: 50px;
    margin: 0 auto; /* 로고 중앙 정렬 */
    margin-bottom: 0;
}

#search-results.list-view .team-info {
    /* [변경] 정보 영역 내부도 그리드로 분할 (이름 | 순위정보) */
    display: grid;
    grid-template-columns: 1fr auto; /* 이름(가변) | 순위(자동) */
    align-items: center;
    gap: 10px;
    width: 100%;
}

/* [신규] 그룹형 스타일 */
#search-results.group-view {
    display: block; /* 블록 레이아웃 (그룹들을 세로로 쌓음) */
}

.group-section {
    margin-bottom: 20px;
}

.group-header {
    background-color: #f1f3f5;
    padding: 8px 12px;
    font-weight: bold;
    border-radius: 6px;
    margin-bottom: 10px;
    color: #333;
    font-size: 1rem;
    border-left: 4px solid #333;
    overflow-x: auto; /* 테이블이 길어질 경우 스크롤 */
}

.group-items {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 그룹 내부에서는 바둑판형 */
    gap: 10px;
}

/* [신규] 그룹 헤더 내 순위표 스타일 */
.group-standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    background: white;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
    border: 1px solid #eee;
}

.group-standings-table th,
.group-standings-table td {
    padding: 6px 8px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
}

.group-standings-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #555;
}

/* [신규] 토너먼트 타이틀 스타일 */
.tournament-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 20px 0 10px 0;
    color: #333;
    width: 100%;
}

/* [신규] 토너먼트 대진표 스타일 (월드컵용 좌우 대칭) */
.tournament-container {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    justify-content: center;
    padding: 20px 0;
}
.bracket-column {
    flex: 1;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.match-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s;
}
.match-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.match-number {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
}

/* [신규] 도움말 콘텐츠 스타일 */
.help-content h3 {
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    margin-top: 20px;
    color: #2196f3;
}

.help-content ul {
    list-style-type: disc;
    padding-left: 20px;
    line-height: 1.6;
}

.help-content li {
    margin-bottom: 5px;
}

/* [신규] 텍스트 버튼 스타일 (더보기 등) */
.text-btn {
    background: none;
    border: none;
    color: #2196f3;
    cursor: pointer;
    font-weight: bold;
    padding: 5px 0;
    display: none; /* JS로 제어 */
}
.text-btn:hover {
    text-decoration: underline;
}
.team-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    cursor: pointer;
}
.team-slot:hover { background-color: #f9f9f9; border-radius: 4px; }
.team-slot.empty { color: #999; font-style: italic; cursor: default; }
.team-slot .logo { width: 24px; height: 24px; object-fit: contain; }
.team-slot .name { font-weight: bold; font-size: 0.9rem; }
.team-slot .rank { font-size: 0.75rem; color: #666; background: #eee; padding: 1px 4px; border-radius: 3px; white-space: nowrap; }

/* 왼쪽 진영: 로고가 오른쪽 (텍스트 왼쪽 정렬) -> flex-direction: row-reverse */
.bracket-column.left .team-slot {
    flex-direction: row-reverse;
    text-align: right;
    justify-content: flex-start;
}

/* 오른쪽 진영: 로고가 왼쪽 (텍스트 오른쪽 정렬) -> flex-direction: row */
.bracket-column.right .team-slot {
    flex-direction: row;
    text-align: left;
    justify-content: flex-start;
}

.vs-divider {
    height: 1px;
    background: #eee;
    width: 100%;
    position: relative;
}

/* [신규] 챔피언스리그 트리형 대진표 스타일 */
.cl-tournament-tree {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 20px;
    padding: 20px;
    overflow-x: auto;
    min-width: 1000px; /* 가로 스크롤 확보 */
    position: relative; /* SVG 위치 기준 */
}
.tree-column {
    display: flex;
    flex-direction: column;
    justify-content: space-around; /* 카드들을 세로로 균등 배치 */
    flex: 1;
    gap: 20px;
}
.tree-column.final-column {
    justify-content: center;
    flex: 0 0 200px; /* 결승전은 너비 고정 */
}
.cl-match-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-size: 0.85rem;
    position: relative;
    text-align: center;
}

/* [신규] SVG 대진표 라인 컨테이너 */
.bracket-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}
.cl-match-card { z-index: 1; } /* 선보다 위에 카드 배치 */

.cl-match-card .round-name {
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 5px;
    display: block;
}
.cl-match-card .team-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
}
.cl-match-card .team-row img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}
.cl-match-card .score {
    font-weight: bold;
    color: #333;
}
.cl-match-card .winner {
    color: #2196f3;
    font-weight: bold;
}

/* [신규] 반응형 미디어 쿼리 */

/* 태블릿 및 작은 화면 (1024px 이하) */
@media screen and (max-width: 1024px) {
    .squad-container {
        flex-wrap: wrap; /* 줄바꿈 허용 */
        overflow-y: auto; /* 세로 스크롤 허용 */
        height: auto; /* 높이 자동 조절 */
        min-height: 0;
    }
    
    /* 필드 영역: 상단 배치, 너비 50%씩 */
    .field-wrapper {
        order: 1;
        width: 50%;
        flex: none;
        height: 50vh; /* 화면 높이의 50% 사용 */
        margin: 0;
    }
    
    /* 선수 목록: 하단 배치, 너비 50%씩 */
    .player-list {
        order: 2;
        width: 50%;
        flex: none;
        height: auto;
        max-height: 400px; /* 목록 높이 제한 및 스크롤 */
        border-bottom: 1px solid #ddd;
    }
    
    #list-left { border-right: 1px solid #ddd; }
    #list-right { border-left: none; }
}

/* 모바일 화면 (768px 이하) */
@media screen and (max-width: 768px) {
    /* 스코어보드 재배치 */
    .scoreboard {
        height: auto;
        padding: 10px;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .site-logo {
        position: static;
        transform: none;
        height: 30px;
        margin-bottom: 5px;
    }
    
    .team-wrapper {
        height: 40px;
    }
    
    .score-box {
        height: 40px;
    }
    
    .timer-wrapper {
        width: 100%;
        justify-content: center;
        margin-top: 5px;
    }
    
    /* 선수 목록 너비 100% (세로로 쌓임) */
    .player-list {
        width: 100%;
        border-right: none;
    }
    
    /* 모달 크기 조정 */
    .modal-content {
        width: 95%;
        margin: 20px auto;
        max-height: 90vh;
    }
    
    /* 검색 결과 그리드 3열로 변경 */
    #search-results.grid-view {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 초소형 화면 (480px 이하) */
@media screen and (max-width: 480px) {
    #search-results.grid-view {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .team .player {
        width: 50px; /* 선수 아이콘 크기 축소 */
    }
    .team .player .player-number {
        width: 40px;
        height: 32px;
        font-size: 1rem;
    }
    .team .player .player-name {
        font-size: 0.7rem;
    }
}

.search-result-item {
    display: flex;
    flex-direction: column; /* [변경] 세로 정렬 (로고 위, 이름 아래) */
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    border: 1px solid #eee; /* 박스 테두리 추가 */
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    margin-bottom: 0;
    text-align: center;
    background-color: #fff;
}

.search-result-item:hover { 
    background-color: #f0f7ff; 
    transform: translateY(-3px); /* 호버 시 살짝 떠오르는 효과 */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.team-logo {
    width: 60px; /* [변경] 로고 크기 확대 */
    height: 60px;
    margin-right: 0;
    margin-bottom: 10px;
    object-fit: contain;
    background-color: transparent;
    border: none;
    padding: 0;
}

/* [신규] 로고 없을 때 대체 스타일 */
.team-logo.team-logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
    color: #888;
    font-size: 1.8rem;
    font-weight: bold;
    border-radius: 50%;
    border: 2px solid #e0e0e0;
}

.team-info { display: flex; flex-direction: column; justify-content: center; width: 100%; }
.team-name-txt { font-weight: bold; font-size: 1rem; color: #333; margin-bottom: 2px; }
.team-country { font-size: 0.8rem; color: #666; }
.team-name-txt .english-name {
    font-size: 0.85em;
    color: #888;
    font-weight: normal;
    margin-left: 4px;
    display: block; /* [변경] 영문 이름 줄바꿈 */
}

/* [신규] 선수 이름 내 영문 표기 스타일 */
/* 리스트 내 영문 이름 */
.player-list .player-name .english-name {
    font-size: 0.85em;
    color: #666;
    font-weight: normal;
    margin-left: 4px;
}
/* 필드 위 영문 이름 */
.team .player .player-name .english-name {
    font-size: 0.8em;
    color: #ddd;
    font-weight: normal;
    margin-left: 3px;
}

/* [신규] 검색 결과 내 순위 정보 스타일 */
.team-standing {
    margin-top: 6px; /* 바둑판형일 때 여백 */
    font-size: 0.85rem;
    color: #555;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    text-align: left;
}

/* 리스트형일 때 순위 정보 스타일 조정 */
#search-results.list-view .team-standing {
    margin-top: 0;
    justify-content: flex-end; /* 오른쪽 정렬 */
}

.rank-badge {
    background-color: #333;
    color: #ffd700;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.8rem;
    white-space: nowrap;
    margin-top: 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* [신규] 스프레드시트 테이블 스타일 */
.spreadsheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.spreadsheet-table th,
.spreadsheet-table td {
    border: 1px solid #ddd;
    padding: 0;
}

.spreadsheet-table th {
    background-color: #f0f0f0;
    padding: 10px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.spreadsheet-table input,
.spreadsheet-table select {
    width: 100%;
    height: 100%;
    border: none;
    padding: 8px;
    font-size: 0.9rem;
    outline: none;
    background: transparent;
}

.spreadsheet-table input:focus,
.spreadsheet-table select:focus {
    background-color: #e3f2fd;
}

.btn-delete-row {
    background: #ffcdd2;
    color: #c62828;
    border: none;
    width: 100%;
    height: 100%;
    cursor: pointer;
    font-weight: bold;
}

.btn-delete-row:hover {
    background: #ef9a9a;
}

.standing-stats {
    line-height: 1.4;
    font-size: 0.8rem;
}

.standing-goals {
    color: #888;
    font-size: 0.75rem;
}

.loading-msg, .error-msg, .no-result { 
    padding: 20px; text-align: center; color: #666; 
    grid-column: 1 / -1; /* [신규] 메시지는 그리드 전체 너비 사용 */
}
.error-msg { color: #f44336; }

/* 애니메이션 정의 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* [신규] 프리뷰 단계 스타일 */
.preview-header {
    display: flex;
    align-items: center;
    padding: 0 0 15px 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 15px;
}

.preview-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
}

#preview-player-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    padding: 10px;
    background: #fafafa;
}

.preview-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

#btn-preview-back {
    padding: 10px 20px;
    background-color: #9e9e9e;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

#btn-preview-apply {
    padding: 10px 20px;
    background-color: #2196f3;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}