/* Reset CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 스크롤 보장을 위한 전역 설정 */
html {
    /* 스크롤 항상 허용 */
    overflow-y: auto;
    overflow-x: hidden;
}

/* 3색 팔레트 시스템 */
:root {
    --primary-blue: #4A90E2;        /* 저장 버튼용 */
    --primary-blue-light: #A8D0F7;  /* 저장 버튼 호버용 */
    --primary-green: #7ED321;       /* 활성화된 별점용 */
    --primary-green-light: #B8E86B; /* 별점 호버용 */
    --accent-yellow: #FFD700;       /* 심사 기준 배경용 */
    --accent-yellow-light: #FFF3A0; /* 심사 기준 연한 배경용 */
    --dark-gray: #3d3d3d;
    --medium-gray: #6b6b6b;
    --light-gray: #d9d9d9;
    --extra-light-gray: #f5f5f5;
    --white: #ffffff;
}

/* 기본 스타일 */
html, body {
    height: 100vh;
    margin: 0;
    padding: 0;
    /* overflow: hidden 제거 - 스크롤 허용 */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-gray);
    background: var(--extra-light-gray);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    /* overflow: hidden 제거 - 컨테이너 스크롤 허용 */
}

/* 헤더 행 스타일 */
.header-row {
    background: var(--white);
    font-size: small;
    border: 1px solid var(--light-gray);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

/* 헤더 스타일 */
.header {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: var(--dark-gray);
    font-size: 1.5rem;
    margin: 0;
    font-weight: 700;
    flex-shrink: 0;
}

.header .subtitle {
    color: var(--medium-gray);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* 카드 스타일 */
.card {
    background: var(--white);
    border-radius: 10px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--light-gray);
    flex-shrink: 0;
}

/* 버튼 스타일 */
.btn {
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    background: var(--primary-blue-light);
}

.btn-secondary {
    background: var(--dark-gray);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--medium-gray);
}

.btn-success {
    background: var(--primary-blue);
    color: var(--white);
}

.btn-success:hover {
    background: var(--primary-blue-light);
}

.btn:disabled {
    background: var(--light-gray);
    color: var(--medium-gray);
    cursor: not-allowed;
}

/* 로그인 컨테이너 전용 스타일 */
.login-container {
    height: 100vh;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.login-content {
    background: var(--white);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid var(--light-gray);
    max-width: 600px;
    width: 100%;
}

.login-content .header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-content .card {
    background: var(--extra-light-gray);
    margin-bottom: 1.5rem;
}

/* 입력 필드 스타일 */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
}

/* 별점 시스템 스타일 */
.star-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 10px 0;
}

.star {
    font-size: 1.5rem;
    color: #ddd;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.star:hover,
.star.active {
    color: var(--primary-green);
}

.star.hover {
    color: var(--primary-green-light);
}

.star.disabled {
    color: var(--light-gray) !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

.star.disabled:hover {
    color: var(--light-gray) !important;
}

.star.read-only {
    cursor: default !important;
    pointer-events: none;
}

.star.read-only:hover {
    color: inherit;
}

/* 점수 표시 */
.score-display {
    background: var(--light-gray);
    color: var(--dark-gray);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    text-align: center;
    margin-left: 15px;
    min-width: 60px;
    border: 1px solid var(--medium-gray);
}

/* 심사 기준 스타일 */
.criteria-section {
    background: var(--accent-yellow-light);
    border: 2px solid var(--accent-yellow);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.criteria-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.criteria-item:last-child {
    border-bottom: none;
}

.criteria-info {
    flex: 1;
}

.criteria-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
}

.criteria-description {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
}

.criteria-score {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 메인 콘텐츠 레이아웃 */
.main-content {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    margin-top: 0.5rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.judge-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    overflow-y: auto;
    height: 100%;
    /* 더 안전한 높이 계산 - 브라우저 호환성 개선 */
    max-height: 70vh;
    min-height: 400px;
    padding-right: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--light-gray) transparent;
    /* iOS Safari 호환성 개선 */
    -webkit-overflow-scrolling: touch;
}

.judge-area::-webkit-scrollbar {
    width: 6px;
}

.judge-area::-webkit-scrollbar-track {
    background: transparent;
}

.judge-area::-webkit-scrollbar-thumb {
    background: var(--light-gray);
    border-radius: 3px;
}

.judge-area::-webkit-scrollbar-thumb:hover {
    background: var(--medium-gray);
}

.sidebar-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.criteria-panel {
    background: white;
    border: 2px solid var(--accent-yellow);
    border-radius: 8px;
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
}

/* 별표 순서 박스 스타일 */
.star-order-box {
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    padding: 0.8rem;
    background: var(--white);
    transition: all 0.3s ease;
    height: fit-content;
    margin-bottom: 0.8rem;
}

.star-order-box.active {
    border-color: var(--primary-blue);
    background: var(--white);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.2);
}

.star-order-box.disabled {
    opacity: 0.6;
    pointer-events: none;
    background: var(--extra-light-gray);
    border-color: var(--light-gray);
}

/* 별표 순서 박스 헤더 */
.star-order-header {
    background: var(--light-gray);
    color: var(--dark-gray);
    padding: 0.5rem 1rem;
    margin: -1rem -1rem 1rem -1rem;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
}

.star-order-box.disabled .star-order-header {
    background: var(--medium-gray);
    color: var(--white);
}

.star-order-box.active .star-order-header {
    background: var(--primary-blue);
    color: var(--white);
}

/* 별표 순서 박스 내부 심사 기준 */
.box-criteria-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
    padding: 0.3rem 0;
}

.box-criteria-item:last-of-type {
    margin-bottom: 0.8rem;
}

.box-criteria-name {
    font-weight: 600;
    font-size: 1.05rem;
    color: #333;
}

.box-criteria-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.box-star-rating {
    display: flex;
    gap: 2px;
}

.box-star-rating .star {
    font-size: 1.4rem;
}

.box-score {
    background: var(--light-gray);
    color: var(--dark-gray);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 35px;
    text-align: center;
}

.box-score-input {
    background: var(--light-gray);
    color: var(--dark-gray);
    border: 2px solid var(--medium-gray);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
    width: 70px;
}

.box-score-input:focus {
    outline: none;
    background: var(--white);
    color: var(--dark-gray);
    border-color: var(--primary-blue);
}

/* 저장 버튼 */
.save-btn {
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 0.5rem;
}

.save-btn:hover {
    background: var(--primary-blue-light);
}

.save-btn:disabled {
    background: var(--light-gray);
    color: var(--medium-gray);
    cursor: not-allowed;
}

.total-score {
    background: var(--light-gray);
    color: var(--dark-gray);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1.2rem;
    text-align: center;
    margin-top: 1rem;
}

/* 모드 전환 버튼 */
.mode-switch {
    text-align: center;
    margin: 0.5rem 0;
    flex-shrink: 0;
}

.mode-indicator {
    background: var(--white);
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    text-align: center;
    border: 1px solid var(--light-gray);
    flex-shrink: 0;
}

.mode-indicator h2 {
    color: var(--dark-gray);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.3rem 0;
    letter-spacing: -0.5px;
}

.mode-indicator p {
    color: var(--medium-gray);
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.3;
    font-weight: 400;
}

/* 진행률 표시 */
.progress-indicator {
    background: var(--white);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--light-gray);
    white-space: nowrap;
    margin-bottom: 1rem;
}

.progress-text {
    font-weight: 600;
    color: #333;
}

/* 로딩 애니메이션 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 반응형 디자인 */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr 250px;
        gap: 1.5rem;
    }

    .criteria-panel {
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
        min-height: 100vh;
        /* height 제거하여 자연스러운 스크롤 허용 */
    }

    .header h1 {
        font-size: 2rem;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 1rem;
        flex: 1;
        min-height: 0;
    }

    .judge-area {
        grid-template-columns: 1fr;
        gap: 1rem;
        overflow-y: auto;
        height: auto;
        /* 모바일에서 더 안전한 높이 설정 */
        max-height: 60vh;
        min-height: 300px;
        /* iOS 스크롤 개선 */
        -webkit-overflow-scrolling: touch;
    }

    .criteria-panel {
        position: static;
        order: -1;
        padding: 1rem;
        overflow-y: auto;
        max-height: 200px;
        -webkit-overflow-scrolling: touch;
    }

    .star-order-box {
        padding: 0.8rem;
    }

    .star-order-header {
        padding: 0.4rem 0.8rem;
        margin: -0.8rem -0.8rem 0.8rem -0.8rem;
        font-size: 0.9rem;
    }

    .box-criteria-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .box-criteria-controls {
        width: 100%;
        justify-content: space-between;
    }

    .box-star-rating .star {
        font-size: 1.5rem;
    }

    .card {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .star {
        font-size: 1.2rem;
    }

    .box-star-rating .star {
        font-size: 1.3rem;
    }

    .card {
        padding: 1rem;
    }

    .star-order-box {
        padding: 0.6rem;
    }

    .star-order-header {
        padding: 0.3rem 0.6rem;
        margin: -0.6rem -0.6rem 0.6rem -0.6rem;
        font-size: 0.85rem;
    }

    .box-criteria-name {
        font-size: 0.95rem;
    }

    .save-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}

/* 최종 확인 화면 스타일 */
.confirmation-view {
    height: 100%;
    overflow-y: auto;
    padding-right: 0.5rem;
    max-height: 70vh;
    min-height: 400px;
    -webkit-overflow-scrolling: touch;
}

.confirmation-teams {
    max-height: none; /* 제한 제거 */
    overflow-y: visible; /* 부모의 스크롤 사용 */
}

/* 제출 완료 알림 모달 스타일 */
.submit-success-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.submit-success-content {
    background: var(--white);
    border: 2px solid var(--primary-blue);
    border-radius: 10px;
    padding: 3rem 2rem;
    text-align: center;
    max-width: 450px;
    margin: 20px;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.submit-success-content h2 {
    color: var(--dark-gray);
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.submit-success-content p {
    color: var(--medium-gray);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.success-timer {
    background: var(--primary-blue-light);
    color: var(--dark-gray);
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid var(--primary-blue);
}

/* 최종 점수 요약 스타일 */
.final-scores-summary {
    text-align: left;
    margin: 2rem 0;
}

.summary-header h3 {
    color: var(--dark-gray);
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    text-align: center;
    border-bottom: 2px solid var(--primary-blue);
    padding-bottom: 0.5rem;
}

.teams-scores {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.team-score-card {
    background: var(--extra-light-gray);
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    padding: 1rem;
}

.team-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    background: var(--light-gray);
    padding: 0.5rem 1rem;
    border-radius: 6px;
}

.team-rank {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dark-gray);
}

.team-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-gray);
}

/* 순위별 특별 스타일 */
.rank-first {
    border: 2px solid #ffd700;
    background: #fffef7;
}

.rank-first .team-header {
    background: linear-gradient(135deg, #ffd700, #ffed4a);
}

.rank-second {
    border: 2px solid #c0c0c0;
    background: #f9f9f9;
}

.rank-second .team-header {
    background: linear-gradient(135deg, #c0c0c0, #e5e5e5);
}

.rank-third {
    border: 2px solid #cd7f32;
    background: #fefbf7;
}

.rank-third .team-header {
    background: linear-gradient(135deg, #cd7f32, #daa520);
}

.criteria-scores {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.criterion-score {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0.5rem;
    background: var(--white);
    border-radius: 4px;
    border: 1px solid var(--light-gray);
}

.criterion-name {
    font-size: 0.85rem;
    color: var(--medium-gray);
}

.score-value {
    font-weight: 600;
    color: var(--dark-gray);
    font-size: 0.9rem;
}

.total-score-display {
    text-align: center;
    background: var(--light-gray);
    color: var(--dark-gray);
    padding: 0.6rem;
    border-radius: 6px;
    font-size: 1.1rem;
}

.summary-footer {
    border-top: 2px solid var(--primary-blue);
    padding-top: 1rem;
}

.overall-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--medium-gray);
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--dark-gray);
}

/* 발표 심사 단계 안내 스타일 */
.step-indicator {
    background: var(--extra-light-gray);
    padding: 0.6rem 1rem;
    border-radius: 20px;
    border: none;
    flex-shrink: 0;
    max-width: 450px;
}

.steps-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.step-item.active {
    opacity: 1;
}

.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--light-gray);
    color: var(--medium-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.step-item.active .step-circle {
    background: var(--primary-blue);
    color: var(--white);
    box-shadow: 0 2px 6px rgba(74, 144, 226, 0.3);
}

.step-label {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--medium-gray);
    line-height: 1.1;
    margin-top: 0.4rem;
}

.step-item.active .step-label {
    color: var(--dark-gray);
}

.step-label small {
    font-size: 0.5rem;
    font-weight: 400;
    color: var(--medium-gray);
}

.step-arrow {
    font-size: 1.2rem;
    color: var(--light-gray);
    font-weight: normal;
    margin: 0;
    align-self: center;
    margin-top: -1.5rem;
}

/* 인라인 단계 표시 스타일 */
.step-indicator-inline {
    flex-shrink: 0;
    background: var(--extra-light-gray);
    padding: 0.4rem 0.8rem;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
}

.step-indicator-inline .steps-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.step-indicator-inline .step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.step-indicator-inline .step-item.active {
    opacity: 1;
}

.step-indicator-inline .step-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--light-gray);
    color: var(--medium-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.step-indicator-inline .step-item.active .step-circle {
    background: var(--primary-blue);
    color: var(--white);
    box-shadow: 0 2px 4px rgba(74, 144, 226, 0.3);
}

.step-indicator-inline .step-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-align: center;
    color: var(--medium-gray);
    transition: color 0.3s ease;
    line-height: 1.2;
}

.step-indicator-inline .step-item.active .step-label {
    color: var(--primary-blue);
    font-weight: 600;
}

.step-indicator-inline .step-label small {
    font-size: 0.4rem;
    font-weight: 400;
    color: var(--medium-gray);
}

.step-indicator-inline .step-arrow {
    font-size: 0.9rem;
    color: #bbb;
    font-weight: normal;
    margin: 0 0.1rem;
    align-self: center;
    margin-top: -0.8rem;
}

/* 모드 헤더 레이아웃 */
.mode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 0.2rem 0;
}

.mode-text {
    flex: 1;
    min-width: 0; /* flex item이 줄어들 수 있도록 */
}

/* 모바일 반응형 */
@media (max-width: 768px) {
    .mode-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .step-indicator-inline {
        align-self: center;
        padding: 0.3rem 0.6rem;
    }

    .step-indicator-inline .step-circle {
        width: 22px;
        height: 22px;
        font-size: 0.65rem;
    }

    .step-indicator-inline .step-label {
        font-size: 0.55rem;
    }

    .criteria-scores {
        grid-template-columns: 1fr;
    }

    .overall-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .teams-scores {
        max-height: 300px;
    }

    .team-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .header-row {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    .steps-container {
        justify-content: center;
        gap: 0.4rem;
    }

    .step-arrow {
        font-size: 1rem;
        margin: 0 0.2rem;
    }

    .step-circle {
        width: 20px;
        height: 20px;
        font-size: 0.65rem;
    }

    .step-label {
        font-size: 0.55rem;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 1rem;
        flex: 1;
        min-height: 0;
    }

    .sidebar-panel {
        order: -1;
        max-height: 150px;
    }
}