body {
    margin: 0; padding: 0;
    background-color: #f8fafc;
    display: flex; align-items: center; justify-content: center;
    height: 100vh;
    font-family: 'Pretendard', sans-serif;
    overflow: hidden;
    flex-direction: column;
    transition: background-color 0.3s;
}

body.dark-mode {
    background-color: #121212;
}

/* 독립 페이지용 컨테이너 */
.standalone-wrapper {
    width: fit-content; /* 컨텐츠(스코어보드) 너비에 맞춤 */
    min-width: 800px;    /* 스코어보드 최소 너비와 동기화 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transform: scale(1.4); /* 전체적으로 큼직하게 보이기 */
    position: relative;
    transition: transform 0.3s ease-in-out;
}

/* 1차전 스코어 표시 영역 (스코어 박스 기준 절대 위치) */
.first-leg-display {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.9);
    color: #ffd700;
    padding: 2px 0;
    border-radius: 6px 6px 0 0;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    z-index: 5;
    border: 1px solid #333;
    border-bottom: none;
}
.first-leg-display.show { display: block; }

/* 1차전 스코어 직접 입력 필드 */
.first-leg-input {
    background: transparent;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    width: 24px;
    outline: none;
    cursor: pointer;
}
.first-leg-input:not([readonly]) {
    cursor: text;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* index.html의 스코어보드 구조와 동일하게 유지 */
.scoreboard {
    width: 100%; /* 부모(wrapper) 너비에 맞춤 */
    min-width: 800px;
    background: white;
    border-radius: 0; /* 모서리 사각 처리 */
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    position: relative;
}

/* 호버 시 버튼 노출 로직 */
.timer-wrapper .match-controls {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 8px;
    border-radius: 0; /* 모서리 사각 처리 */
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    white-space: nowrap;
    gap: 4px;
}

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

.match-controls button {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 5px 10px;
    border-radius: 0; /* 모서리 사각 처리 */
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.match-controls button:hover { background: #e2e8f0; }
.match-controls button.active {
    background: #000 !important;
    color: #fff !important;
    border-color: #000;
}

.score-input:focus { outline: none; }
.timer-part:focus { outline: none; }

/* PK 바 간격 제거 및 일체화 */
.pk-bar {
    position: absolute; /* 스코어보드를 밀어 올리지 않도록 절대 위치 */
    top: 100%; /* 스코어보드 바로 아래에 부착 */
    left: 0;
    right: 0;
    width: 100%;
    margin-top: 0;
    border-radius: 0; /* 모서리 사각 처리 */
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    background: #000;
    border-top: 1px solid #333;
}

/* [보완] 팀 검색 그리드 뷰 스타일 최적화 (팀명 미표시 문제 해결) */
#search-results.grid-view {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
    gap: 12px !important;
    padding: 10px !important;
}

#search-results.grid-view .search-result-item {
    min-height: 140px !important;
    padding: 10px 5px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}

#search-results.grid-view .team-name {
    display: block !important;
    width: 100% !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    text-align: center !important;
    color: #1e293b !important;
    margin-top: 8px !important;
    white-space: normal !important; /* 줄바꿈 허용 */
    line-height: 1.2 !important;
    padding: 0 !important;
}

#search-results.grid-view .team-logo {
    width: 50px !important;
    height: 50px !important;
    margin-bottom: 0 !important;
}

/* 팀 컨트롤 메뉴 노출 */
.team-wrapper.show-controls .team-controls { display: flex; }
.color-picker-input { width: 0; height: 0; visibility: hidden; position: absolute; }
.modal { z-index: 2000; }
#search-results { max-height: 400px; overflow-y: auto; }

/* 반응형 처리: 화면 크기에 맞춰 전체 스케일 조정 */
@media (max-width: 1200px) {
    .standalone-wrapper { transform: scale(1.2); }
}
@media (max-width: 992px) {
    .standalone-wrapper { transform: scale(1); }
}
@media (max-width: 850px) {
    .standalone-wrapper { transform: scale(0.85); }
}
@media (max-width: 768px) {
    .standalone-wrapper { transform: scale(0.7); }
}
@media (max-width: 600px) {
    .standalone-wrapper { transform: scale(0.55); }
}
@media (max-width: 480px) {
    .standalone-wrapper { transform: scale(0.45); }
}
@media (max-width: 380px) {
    .standalone-wrapper { transform: scale(0.35); }
}