/* 기본 설정 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --secondary-color: #10B981;
    --danger-color: #EF4444;
    --background: #F9FAFB;
    --surface: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Malgun Gothic', '맑은 고딕',
                 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* 헤더 */
header {
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary-color), #7C3AED);
    color: white;
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.5s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-text {
    flex: 1;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 8px;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 헤더 내 앱 사용법 링크 */
header .usage-guide-link {
    color: white;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    padding: 10px 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    transition: all 0.3s ease;
    white-space: nowrap;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.1);
}

header .usage-guide-link:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.7);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

header .usage-guide-link:active {
    transform: translateY(0);
}

header .usage-guide-link:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* 모바일 반응형 */
@media (max-width: 600px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
    }

    .header-text {
        text-align: center;
    }

    header .usage-guide-link {
        font-size: 0.9rem;
        padding: 8px 16px;
    }
}

/* 진행 표시기 */
.progress-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    padding: 0 20px;
    animation: fadeIn 0.5s ease 0.2s backwards;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.progress-step::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--border-color);
    z-index: 0;
    transition: background 0.3s ease;
}

.progress-step:last-child::before {
    display: none;
}

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

.progress-step.active::before {
    background: var(--primary-color);
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

.progress-step.active .step-circle {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

.step-label {
    margin-top: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-step.active .step-label {
    color: var(--primary-color);
}

/* 단계 컨테이너 */
.step-container {
    display: none;
    animation: slideIn 0.4s ease;
}

.step-container.active {
    display: block;
}

.step-container.slide-out-left {
    animation: slideOutLeft 0.4s ease;
}

.step-container.slide-out-right {
    animation: slideOutRight 0.4s ease;
}

/* 섹션 */
.section {
    background: var(--surface);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    min-height: 400px;
}

.section h2 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 24px;
    text-align: center;
}

.section-description {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* CSV 업로드 */
.upload-area {
    text-align: center;
    padding: 60px 40px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background: var(--background);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover,
.upload-area:focus {
    border-color: var(--primary-color);
    background: #EEF2FF;
    outline: none;
}

#csvFile {
    display: none;
}

.file-select-btn {
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: transparent;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    width: 100%;
}

.file-select-btn:hover {
    opacity: 0.8;
}

.file-select-btn:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 4px;
    border-radius: 8px;
}

.file-icon {
    font-size: 4rem;
    animation: float 3s ease-in-out infinite;
}

.file-text {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 600;
}

.file-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.file-formats-hint {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    opacity: 0.7;
}

.file-warning {
    margin-top: 12px;
    padding: 10px 16px;
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #F59E0B;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

.sheet-selector {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

.sheet-selector label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.sheet-selector select {
    padding: 8px 12px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.sheet-selector select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.sheet-selector select:hover {
    border-color: var(--primary-hover);
}

.file-info {
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-delete-btn {
    margin-top: 16px;
    padding: 10px 20px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.file-delete-btn:hover {
    background: #DC2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

.file-delete-btn:focus {
    outline: 3px solid var(--danger-color);
    outline-offset: 2px;
}

.sample-download-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.sample-download-btn:hover {
    background: #1E40AF;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.sample-download-btn:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.student-count {
    margin-top: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #DBEAFE, #EEF2FF);
    border-radius: 12px;
    text-align: center;
    font-size: 1.2rem;
}

.student-count strong {
    color: var(--primary-color);
    font-size: 1.5rem;
}

/* 탭 UI */
.input-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: var(--background);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-btn:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: -3px;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-panel.active {
    display: block;
}

/* 최근 학급 UI */
.recent-classes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recent-empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 32px 16px;
    font-size: 1rem;
}

.recent-class-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.recent-class-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.recent-class-info {
    flex: 1;
    min-width: 0;
}

.recent-class-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-class-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.recent-class-actions {
    display: flex;
    gap: 8px;
    margin-left: 12px;
    flex-shrink: 0;
}

.recent-load-btn {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: inherit;
}

.recent-load-btn:hover {
    background: var(--primary-hover);
}

.recent-delete-btn {
    padding: 8px 12px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.recent-delete-btn:hover {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

/* 직접 입력 UI */
.manual-input-section {
    margin-bottom: 24px;
}

.manual-input-section h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.common-info-inputs {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.common-info-inputs label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.common-info-inputs input[type="number"] {
    width: 80px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.common-info-inputs input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Textarea */
#manualNames {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.2s ease;
}

#manualNames:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

#manualNames::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* 성별 토글 */
.gender-toggle-wrapper {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.gender-toggle-wrapper > label {
    font-weight: 500;
}

.gender-toggle {
    display: inline-flex;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

.toggle-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    min-width: 70px;
}

.toggle-btn:hover {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

.toggle-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.toggle-btn:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* 미리보기 리스트 */
.preview-list {
    max-height: 300px;
    overflow-y: auto;
    background: var(--background);
    border-radius: 8px;
    padding: 12px;
}

.preview-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--surface);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
    animation: slideIn 0.3s ease;
}

.preview-item:last-child {
    margin-bottom: 0;
}

.preview-info {
    flex: 1;
    font-size: 0.95rem;
}

.preview-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.preview-details-editable {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.preview-grade-class {
    color: var(--text-secondary);
}

.preview-number-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.preview-number-input {
    width: 50px;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
    background: var(--background);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.preview-number-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.preview-gender-toggle {
    display: inline-flex;
    gap: 2px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px;
}

.preview-gender-btn {
    padding: 4px 8px;
    border: none;
    background: transparent;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.preview-gender-btn.active {
    background: var(--primary-color);
    color: white;
}

.preview-gender-btn:hover:not(.active) {
    background: var(--background);
    color: var(--text-primary);
}

.preview-gender-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3);
}

.preview-item-delete {
    padding: 6px 12px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preview-item-delete:hover {
    background: #DC2626;
    transform: scale(1.05);
}

.preview-item-delete:focus {
    outline: 3px solid var(--danger-color);
    outline-offset: 2px;
}

/* 설정 그룹 */
.setting-group {
    margin-bottom: 32px;
}

.setting-group h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.setting-group label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    margin-right: 12px;
}

.checkbox-label {
    cursor: pointer;
    padding: 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.checkbox-label:hover {
    background: var(--background);
}

.setting-group input[type="number"],
.setting-group input[type="text"] {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    width: auto;
    min-width: 100px;
    margin: 0 8px;
    transition: all 0.2s ease;
}

.setting-group input[type="number"]:focus,
.setting-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.setting-group input[type="text"] {
    width: 100%;
    max-width: 500px;
    margin: 8px 0;
}

.setting-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.gender-settings {
    margin-top: 16px;
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
    animation: slideDown 0.3s ease;
}

.gender-input {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gender-input:last-child {
    margin-bottom: 0;
}

/* Opt-out 컨테이너 */
.optout-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
    background: var(--background);
    border-radius: 8px;
}

/* 토글 헤더 (접기/펼치기) */
.toggle-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    font-family: inherit;
}

.toggle-header:hover {
    background: var(--background);
}

.toggle-header:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.toggle-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.toggle-icon {
    font-size: 1rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.toggle-header[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

/* 인라인 Opt-out 컨테이너 (접기/펼치기) */
.optout-container-inline {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
    margin-top: 8px;
    background: var(--background);
    border-radius: 8px;
    animation: expandDown 0.3s ease;
}

@keyframes expandDown {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
    to {
        opacity: 1;
        max-height: 400px;
        padding-top: 16px;
        padding-bottom: 16px;
    }
}

.student-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.student-checkbox:hover {
    background: #EEF2FF;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.student-checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.student-checkbox.excluded {
    background: #FEE2E2;
    border-color: var(--danger-color);
}

.student-info {
    flex: 1;
    font-size: 0.9rem;
}

.student-name {
    font-weight: 600;
    color: var(--text-primary);
}

.student-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* 테마 선택 */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.theme-card {
    display: block;
    padding: 32px 24px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--surface);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    width: 100%;
}

.theme-card:hover,
.theme-card:focus {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
    outline: none;
}

.theme-card[aria-checked="true"] {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #EEF2FF, #DBEAFE);
    box-shadow: var(--shadow-md);
    border-width: 3px;
}

.theme-icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

.theme-name {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.theme-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 네비게이션 버튼 */
.step-navigation {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 24px;
}

.nav-btn {
    flex: 1;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.back-btn {
    background: var(--surface);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    max-width: 150px;
}

.back-btn:hover:not(:disabled) {
    background: var(--background);
    border-color: var(--text-secondary);
}

.next-btn {
    background: linear-gradient(135deg, var(--primary-color), #7C3AED);
    color: white;
    box-shadow: var(--shadow-md);
}

.next-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.next-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.start-btn {
    background: linear-gradient(135deg, var(--secondary-color), #059669);
    color: white;
    box-shadow: var(--shadow-md);
    font-size: 1.2rem;
}

.start-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* 애니메이션 컨테이너 */
.animation-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    animation: fadeIn 0.5s ease;
}

.animation-container.fullscreen-animation {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    animation: fadeIn 0.8s ease, subtleGlow 3s ease-in-out infinite;
}

@keyframes subtleGlow {
    0%, 100% { box-shadow: inset 0 0 60px rgba(59, 130, 246, 0.1); }
    50% { box-shadow: inset 0 0 80px rgba(139, 92, 246, 0.15); }
}

#threeCanvas {
    width: 100%;
    height: 100%;
}

.animation-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.animation-message {
    font-size: 2.5rem;
    color: white;
    font-weight: 700;
    text-align: center;
    padding: 40px 50px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(139, 92, 246, 0.3));
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    animation: messageGlow 2s ease-in-out infinite;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(255, 255, 255, 0.1);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

@keyframes messageGlow {
    0%, 100% {
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(59, 130, 246, 0.2);
        border-color: rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.6), inset 0 0 30px rgba(139, 92, 246, 0.3);
        border-color: rgba(139, 92, 246, 0.5);
    }
}

/* 결과 */
/* 축하 메시지 */
.congratulations-message {
    text-align: center;
    padding: 32px;
    margin-bottom: 32px;
    background: linear-gradient(135deg, #EEF2FF, #DBEAFE);
    border-radius: 16px;
    border: 2px solid var(--primary-color);
    animation: fadeIn 0.5s ease, pulse 2s ease-in-out infinite;
}

.congratulations-message h3 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 16px;
    font-weight: 700;
}

.congratulations-message p {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.congratulations-gif {
    max-width: 200px;
    height: auto;
    border-radius: 12px;
    margin: 0 auto;
    display: block;
    box-shadow: var(--shadow-md);
}

.result-container {
    padding: 24px;
    background: var(--background);
    border-radius: 12px;
    margin-bottom: 24px;
    max-height: 500px;
    overflow-y: auto;
}

.result-item {
    padding: 20px;
    margin-bottom: 16px;
    background: var(--surface);
    border-left: 4px solid var(--primary-color);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    animation: slideIn 0.3s ease backwards;
}

.result-item:nth-child(1) { animation-delay: 0.1s; }
.result-item:nth-child(2) { animation-delay: 0.2s; }
.result-item:nth-child(3) { animation-delay: 0.3s; }
.result-item:nth-child(4) { animation-delay: 0.4s; }
.result-item:nth-child(5) { animation-delay: 0.5s; }

.result-number {
    display: inline-block;
    width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    margin-right: 16px;
    font-weight: 700;
    font-size: 1.1rem;
}

.result-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-details {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.result-actions {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.action-btn {
    flex: 1;
    min-width: 200px;
    padding: 16px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#saveResultBtn {
    background: var(--secondary-color);
    color: white;
}

#saveResultBtn:hover {
    background: #059669;
    transform: translateY(-2px);
}

#continuePickBtn {
    background: var(--primary-color);
    color: white;
}

#continuePickBtn:hover:not(:disabled) {
    background: #4338ca;
    transform: translateY(-2px);
}

#continuePickBtn:disabled {
    background: #a5b4fc;
    cursor: not-allowed;
    opacity: 0.6;
}

#resetSettingsBtn {
    background: #f59e0b;
    color: white;
}

#resetSettingsBtn:hover {
    background: #d97706;
    transform: translateY(-2px);
}

#resetBtn {
    background: var(--text-secondary);
    color: white;
}

#resetBtn:hover {
    background: var(--text-primary);
    transform: translateY(-2px);
}

/* 이전 선발 결과 */
.result-previous-section {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 2px dashed var(--border-color);
}

.result-previous-title {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.result-item-previous {
    opacity: 0.6;
}

/* 피드백 섹션 */
.feedback-section {
    margin-top: 32px;
    padding: 20px;
    text-align: center;
    background: var(--background);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.feedback-section p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0;
}

.feedback-section a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.feedback-section a:hover {
    color: #3730a3;
    text-decoration: underline;
}

.feedback-section a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* 애니메이션 */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutLeft {
    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

@keyframes slideOutRight {
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* 접근성 - 포커스 스타일 */
button:focus,
input:focus,
.upload-area:focus,
.theme-option:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* 반응형 */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    header p {
        font-size: 1rem;
    }

    .section {
        padding: 24px;
    }

    .progress-bar {
        padding: 0 10px;
    }

    .step-circle {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

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

    .theme-selector {
        grid-template-columns: 1fr;
    }

    .optout-container,
    .optout-container-inline {
        grid-template-columns: 1fr;
    }

    .result-actions {
        flex-direction: column;
    }

    .action-btn {
        min-width: 100%;
    }

    .step-navigation {
        flex-direction: column;
    }

    .back-btn {
        max-width: 100%;
    }

    /* 애니메이션 영역 */
    .animation-message {
        font-size: 1.8rem;
        padding: 30px 40px;
    }

    .picked-students-live {
        width: 95%;
        padding: 20px 24px;
        top: 80px;
        max-height: 70vh;
    }

    .picked-student-item {
        font-size: 1.1rem;
        padding: 14px 20px;
    }

    /* 일시 정지 메뉴 */
    .pause-content {
        padding: 32px;
        max-width: 90%;
    }

    .pause-content h2 {
        font-size: 1.6rem;
    }

    .pause-content p {
        font-size: 1rem;
    }

    /* 축하 메시지 */
    .congratulations-message h3 {
        font-size: 1.5rem;
    }

    .congratulations-message p {
        font-size: 1.1rem;
    }

    .congratulations-gif {
        max-width: 150px;
    }

    /* 결과 */
    .result-name {
        font-size: 1.1rem;
    }

    .result-number {
        width: 32px;
        height: 32px;
        line-height: 32px;
        font-size: 1rem;
    }

    /* 피드백 섹션 */
    .feedback-section {
        padding: 16px;
        margin-top: 24px;
    }

    .feedback-section p {
        font-size: 0.9rem;
    }

    /* 네비게이션 버튼 */
    .nav-btn {
        padding: 14px 24px;
        font-size: 1rem;
    }

    .start-btn {
        font-size: 1.1rem;
    }

    /* 직접 입력 */
    .tab-btn {
        font-size: 1rem;
        padding: 10px 16px;
    }

    #manualNames {
        font-size: 0.95rem;
        padding: 12px;
    }

    .toggle-btn {
        padding: 8px 16px;
        font-size: 0.95rem;
        min-width: 60px;
    }

    .common-info-inputs input[type="number"] {
        width: 70px;
        font-size: 0.95rem;
    }

    .preview-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .preview-item-delete {
        align-self: flex-end;
    }

    .preview-details-editable {
        font-size: 0.8rem;
        gap: 6px;
    }

    .preview-number-input {
        width: 45px;
        font-size: 0.8rem;
        padding: 3px 6px;
    }

    .preview-gender-btn {
        font-size: 0.75rem;
        padding: 3px 6px;
    }
}

/* 스크롤바 스타일 */
.optout-container::-webkit-scrollbar,
.result-container::-webkit-scrollbar {
    width: 8px;
}

.optout-container::-webkit-scrollbar-track,
.result-container::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

.optout-container::-webkit-scrollbar-thumb,
.result-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.optout-container::-webkit-scrollbar-thumb:hover,
.result-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 선발 중 학생 표시 */
.picked-students-live {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(240, 245, 255, 0.98));
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-radius: 20px;
    padding: 28px 32px;
    max-height: 65vh;
    overflow-y: auto;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4), inset 0 0 30px rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
}

.picked-student-item {
    padding: 18px 24px;
    margin: 10px 0;
    background: linear-gradient(135deg, #3B82F6, #8B5CF6, #EC4899);
    color: white;
    border-radius: 16px;
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    animation: pickReveal 0.7s ease backwards, shimmer 3s ease-in-out infinite;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes shimmer {
    0%, 100% { transform: scale(1); box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4); }
    50% { transform: scale(1.02); box-shadow: 0 12px 30px rgba(139, 92, 246, 0.5); }
}

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

/* 애니메이션 컨트롤 */
.animation-controls {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.pause-btn {
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pause-btn:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.pause-btn:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* 일시 중지 메뉴 */
.pause-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.pause-content {
    background: var(--surface);
    padding: 48px;
    border-radius: 16px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.pause-content h2 {
    font-size: 2rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.pause-content p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.pause-actions {
    display: flex;
    gap: 16px;
    flex-direction: column;
}

.pause-actions .action-btn {
    min-width: 100%;
    padding: 16px 24px;
    font-size: 1.1rem;
}

/* 소형 모바일 반응형 */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    header {
        padding: 20px 16px;
        margin-bottom: 20px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header p {
        font-size: 0.9rem;
    }

    .section {
        padding: 16px;
        min-height: 300px;
    }

    .section h2 {
        font-size: 1.4rem;
    }

    /* 진행 표시기 */
    .progress-bar {
        padding: 0 5px;
    }

    .step-circle {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

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

    /* 업로드 영역 */
    .upload-area {
        padding: 40px 20px;
    }

    .file-icon {
        font-size: 3rem;
    }

    .file-text {
        font-size: 1rem;
    }

    /* 테마 카드 */
    .theme-card {
        padding: 24px 16px;
    }

    .theme-icon {
        font-size: 2.5rem;
    }

    .theme-name {
        font-size: 1.1rem;
    }

    .theme-desc {
        font-size: 0.85rem;
    }

    /* 애니메이션 영역 */
    .animation-message {
        font-size: 1.4rem;
        padding: 20px 30px;
    }

    .picked-students-live {
        width: 96%;
        padding: 16px 20px;
        top: 60px;
        max-height: 75vh;
    }

    .picked-student-item {
        font-size: 1rem;
        padding: 12px 16px;
        margin: 8px 0;
    }

    /* 일시 정지 메뉴 */
    .pause-content {
        padding: 24px;
        max-width: 95%;
    }

    .pause-content h2 {
        font-size: 1.4rem;
    }

    .pause-content p {
        font-size: 0.95rem;
        margin-bottom: 24px;
    }

    .pause-btn {
        padding: 12px 24px;
        font-size: 1rem;
    }

    /* 축하 메시지 */
    .congratulations-message {
        padding: 24px;
    }

    .congratulations-message h3 {
        font-size: 1.3rem;
    }

    .congratulations-message p {
        font-size: 1rem;
    }

    .congratulations-gif {
        max-width: 120px;
    }

    /* 결과 */
    .result-item {
        padding: 16px;
    }

    .result-name {
        font-size: 1rem;
    }

    .result-number {
        width: 28px;
        height: 28px;
        line-height: 28px;
        font-size: 0.9rem;
        margin-right: 12px;
    }

    /* 버튼 */
    .nav-btn {
        padding: 12px 20px;
        font-size: 0.95rem;
    }

    .start-btn {
        font-size: 1rem;
        padding: 14px 24px;
    }

    .action-btn {
        padding: 14px 20px;
        font-size: 1rem;
    }

    /* 피드백 섹션 */
    .feedback-section {
        padding: 14px;
        margin-top: 20px;
    }

    .feedback-section p {
        font-size: 0.85rem;
    }

    /* 설정 */
    .setting-group input[type="number"],
    .setting-group input[type="text"] {
        font-size: 0.95rem;
        padding: 10px 14px;
    }

    .student-count {
        font-size: 1.1rem;
    }

    .student-count strong {
        font-size: 1.3rem;
    }

    /* 직접 입력 */
    .tab-btn {
        font-size: 0.9rem;
        padding: 8px 12px;
    }

    .manual-input-section h3 {
        font-size: 1rem;
    }

    #manualNames {
        font-size: 0.9rem;
        padding: 10px;
        rows: 6;
    }

    .gender-toggle-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }

    .toggle-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
        min-width: 55px;
    }

    .common-info-inputs {
        flex-direction: column;
        gap: 12px;
    }

    .common-info-inputs input[type="number"] {
        width: 100%;
    }

    .preview-list {
        max-height: 250px;
    }

    .preview-info {
        font-size: 0.9rem;
    }

    .preview-name {
        font-size: 0.95rem;
    }

    .preview-details-editable {
        font-size: 0.75rem;
        gap: 4px;
    }

    .preview-number-input {
        width: 40px;
        font-size: 0.75rem;
        padding: 2px 4px;
    }

    .preview-gender-btn {
        font-size: 0.7rem;
        padding: 2px 5px;
    }

    .preview-item-delete {
        font-size: 0.8rem;
        padding: 5px 10px;
    }
}

/* 스크린 리더 전용 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
