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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: white;
    color: #333;
    min-height: 100vh;
    position: relative;
}

/* 홈 버튼 스타일 */
.home-button-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.home-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.home-btn:hover {
    transform: translateY(-2px) scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.home-btn:active {
    transform: translateY(0) scale(1);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

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

.page {
    display: none;
}

.page.active {
    display: block;
}

/* 막 선택을 위한 2x2 그리드 */
.act-selection-grid {
    margin-bottom: 30px;
}

.act-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.selection-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.selection-card:hover {
    transform: translateY(-3px);
    border-color: #667eea;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.selection-card h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: #333;
}

.selection-card .hp {
    font-size: 1.1rem;
    font-weight: bold;
    color: #e74c3c;
}

.selection-card .status {
    font-size: 0.9rem;
    color: #27ae60;
    font-weight: bold;
    margin-top: 5px;
}

.selection-card.completed {
    border-color: #27ae60;
    background: linear-gradient(135deg, #f8fff8 0%, #e8f5e8 100%);
}

.selection-card.completed:hover {
    border-color: #27ae60;
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.2);
}

.selection-card.raid-summary-card {
    border-color: #f39c12;
    background: linear-gradient(135deg, #fff8e1 0%, #fef3c7 100%);
}

.selection-card.raid-summary-card:hover {
    border-color: #f39c12;
    box-shadow: 0 8px 25px rgba(243, 156, 18, 0.2);
}

.gate-clear-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.3s ease;
}

.gate-clear-btn:hover {
    background: #c0392b;
}

.breadcrumb {
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 1rem;
    color: #666;
}

.breadcrumb .current {
    color: #667eea;
    font-weight: bold;
}

.damage-input-section {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.raid-info {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.raid-info h3 {
    color: #333;
    margin-bottom: 5px;
}

.raid-info .hp {
    font-size: 1.2rem;
    font-weight: bold;
    color: #e74c3c;
}

/* 파티 컨테이너 - 좌우 분할 */
.party-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.party-section {
    margin-bottom: 30px;
}

.party-title {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 8px 8px 0 0;
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
}

/* 세로 배치를 위한 파티 입력 */
.party-inputs-vertical {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
}

.player-input {
    background: white;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #e0e0e0;
}

.player-input label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    color: #555;
}

.player-input-row {
    display: flex;
    gap: 10px;
    align-items: stretch; /* 핵심 변경: 높이를 꽉 채우도록 설정 */
}

.player-input-row input[type="number"] {
    flex: 1; /* 남는 공간을 모두 차지 */
    min-width: 0;
    padding: 10px; /* 패딩 재조정 */
    border-radius: 6px; /* 통일된 디자인 */
    height: 40px; /* 명시적 높이 설정 */
    box-sizing: border-box;
}

.damage-unit-selector {
    display: flex;
    flex-shrink: 0; /* 너비가 줄어들지 않도록 설정 */
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ddd;
    height: 40px; /* input과 동일한 높이로 설정 */
    min-width: 80px; /* 최소 너비 설정 */
    box-sizing: border-box;
}

.damage-unit-selector input[type="radio"] {
    display: none;
}

.damage-unit-selector label {
    padding: 0;
    margin: 0;
    cursor: pointer;
    background-color: #f0f0f0;
    color: #888;
    transition: all 0.3s ease;
    text-align: center;
    display: flex; /* 수직 중앙 정렬을 위해 추가 */
    align-items: center; /* 수직 중앙 정렬을 위해 추가 */
    justify-content: center; /* 수평 중앙 정렬 */
    flex: 1; /* 너비를 꽉 채우도록 변경 */
    height: 100%; /* 전체 높이를 차지 */
    font-size: 0.9rem;
    font-weight: 500;
}

.damage-unit-selector input[type="radio"]:checked + label {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
}

.player-input input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.player-input input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.controls {
    text-align: center;
    margin: 20px 0;
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.btn-secondary:hover {
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.raid-group-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.raid-group-left, .raid-group-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#raidGroupSelect, #raidGroupNameInput {
    padding: 12px;
    border-radius: 25px;
    border: 1px solid #ddd;
    font-size: 1rem;
    height: 45px; /* 버튼과 높이 통일 */
    box-sizing: border-box;
}

#raidGroupSelect {
    min-width: 200px;
}

#raidGroupNameInput {
    min-width: 180px;
}

#raidGroupSelect:focus, #raidGroupNameInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.results-section {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.damage-chart {
    margin: 30px 0;
}

.party-chart {
    margin-bottom: 40px;
}

.party-chart-title {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    margin-bottom: 15px;
}

.damage-bar {
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid #e0e0e0;
}

.damage-bar-fill {
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    border-radius: 8px;
    transition: width 0.8s ease;
    position: relative;
}

.damage-bar-left {
    display: flex;
    align-items: center;
    flex: 1;
}

.damage-bar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.damage-bar-label {
    font-weight: bold;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.damage-bar-value {
    font-weight: bold;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 30px;
}

.stat-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
}

.stat-card h4 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
}

.back-btn {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid #667eea;
    color: #667eea;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.back-btn:hover {
    background: #667eea;
    color: white;
}

/* 토글 스위치 */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    vertical-align: middle;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #667eea;
}

input:focus + .slider {
    box-shadow: 0 0 1px #667eea;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* 데미지 순위 목록 */
.damage-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.damage-list-item {
    position: relative;
    border-radius: 8px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    height: 45px; /* Fixed height for better bar alignment */
}

.damage-list-item .damage-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 8px;
    transition: width 0.8s ease;
}

.damage-list-item .item-content {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    height: 100%;
    color: white; /* Default text color on the bar */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.damage-list-item .player-info {
    display: flex;
    align-items: center;
}

.damage-list-item .rank {
    font-weight: bold;
    font-size: 1.1rem;
    margin-right: 15px;
    width: 20px;
    text-align: center;
}

.damage-list-item .player-name {
    font-weight: bold;
}

.damage-list-item .damage-value {
    font-weight: bold;
    font-size: 1.1rem;
    text-align: right;
    color: #333; /* 데미지 텍스트를 어두운 색으로 변경 */
    text-shadow: none; /* 텍스트 쉐도우 제거 */
}

.damage-list-item .damage-value .full-damage {
    display: none;
    font-size: 0.9rem;
    opacity: 0.8;
}

.damage-list-item .damage-value .short-damage {
    display: inline;
}

.damage-list-item .contribution {
    font-size: 0.9rem;
    margin-left: 10px;
    opacity: 0.9;
    color: #e74c3c; /* 기여도(%) 텍스트 색상 변경 */
}

/* 레이드 전체 통계 페이지 스타일 */
.raid-summary-info {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.summary-stat .label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.summary-stat .value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #667eea;
}

.gate-breakdown {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.gate-breakdown h3 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.gate-record {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
}

.gate-record h4 {
    color: #667eea;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gate-record .gate-hp {
    font-size: 0.9rem;
    color: #e74c3c;
    font-weight: normal;
}

.gate-players {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.gate-player {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.9rem;
}

.gate-player .name {
    font-weight: bold;
    color: #333;
}

.gate-player .damage {
    color: #667eea;
    font-weight: bold;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .act-row {
        grid-template-columns: 1fr;
    }
    
    .party-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .summary-stats {
        grid-template-columns: 1fr;
    }
    
    .gate-players {
        grid-template-columns: 1fr;
    }
}

/* 기여도 구분선 스타일 */
.contribution-divisions {
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.division-line {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.division-label {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 5px;
    padding: 4px 8px;
    border-radius: 4px;
    color: white;
}

.division-label.janheol {
    background: #e74c3c;
}

.division-label.gangtu {
    background: #f39c12;
}

.division-label.tusa {
    background: #3498db;
}

.division-border {
    width: 100%;
    height: 2px;
    background: #ddd;
}

.division-divider {
    margin: 10px 0;
    padding: 0;
    list-style: none;
}

.divider-line {
    width: 100%;
    height: 1px;
    background: #ddd;
    margin: 5px 0;
}

/* 구간 제목 스타일 */
.section-header {
    list-style: none;
    margin: 0 0 10px 0;
    padding: 0;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 400;
    padding: 2px 8px;
    border-radius: 3px;
    text-align: center;
    color: white;
    margin: 0;
}

.section-header.janheol .section-title {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.section-header.gangtu .section-title {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.section-header.tusa .section-title {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}