/* style.css */
body, html {
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: 'Noto Sans KR', sans-serif;
    background: #f0f2f5;
}

.container {
    width: 100%;
    height: 100%;
    padding: 1rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
    height: 100%;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen.active {
    display: flex;
}

h1 {
    font-size: 3.5rem;
    font-weight: 800;
    color: #333;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

h2 {
    font-size: 1.8rem;
    color: #444;
    margin: 0;
}

button {
    padding: 14px 28px;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(45deg, #5e72e4, #825ee4);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 25px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(-1px);
}

.back-btn {
    background: #6c757d;
}

.back-btn:hover {
    background: #5a6268;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

input[type="text"] {
    padding: 14px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 12px;
    width: calc(100% - 32px);
    margin-bottom: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #5e72e4;
    box-shadow: 0 0 10px rgba(94, 114, 228, 0.3);
}

#team-name-inputs {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- 게임 화면 레이아웃 --- */
.game-layout {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 2rem;
}

.game-area {
    flex: 3; /* 3:1 비율로 왼쪽 영역이 더 넓게 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #fff;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
}

.sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.05);
    height: 100%;
    box-sizing: border-box; /* 높이 계산 문제를 해결하기 위해 추가 */
}

/* --- 점수판 --- */
.scoreboard {
    flex-grow: 1; /* 남은 공간을 모두 차지하도록 */
    min-height: 0; /* 스크롤이 가능하도록 flex 아이템의 최소 높이를 0으로 설정 */
    width: 100%;
    display: flex;
    flex-direction: column; /* 세로로 배치 */
    gap: 1rem;
    overflow-y: auto; /* 세로 스크롤 추가 */
    padding-right: 10px; /* 스크롤바 공간 확보 */
}

/* 스크롤바 스타일링 */
.scoreboard::-webkit-scrollbar {
    width: 6px;
}

.scoreboard::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.scoreboard::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.scoreboard::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 게임 선택 화면의 점수판만 가로로 배치 */
#game-select-scoreboard {
    flex-direction: row; /* 원래대로 되돌림 */
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem; /* 카드 사이 간격 추가 */
    align-items: center;
    padding: 0 2rem; /* 좌우 패딩 추가 */
    box-sizing: border-box; /* 패딩이 너비에 포함되도록 설정 */
    margin-bottom: 2rem; /* 제목과의 간격 */
}

/* 게임 선택 화면의 점수 표시 스타일 */
.game-select-score {
    font-size: 1.8rem; /* 글자 크기 증가 */
    font-weight: bold;
    color: #5e72e4; /* 메인 테마 색상 적용 */
    margin-top: 0.5rem;
    text-align: center;
}

/* 게임 선택 버튼 스타일 */
#game-select-screen .button-group button {
    flex-direction: column;
    padding: 1.5rem;
    width: 180px;
    height: 140px;
    justify-content: center;
    align-items: center;
    display: flex;
    gap: 0.5rem; /* 제목과 아이콘 사이 간격 */
}

.game-title {
    font-size: 1.2rem;
    font-weight: bold;
}

.game-desc {
    font-size: 3rem; /* 아이콘 크기 키움 */
    line-height: 1;
}

/* 1등 카드 스타일 */
#game-select-scoreboard .team-score-card {
    padding: 1.5rem 2rem;
    flex: 1;
    min-width: 180px;
    transition: all 0.3s ease;
}

/* 1등 카드 스타일 */
#game-select-scoreboard .rank-1 {
    background: linear-gradient(145deg, #fff59d, #fbc02d);
    border: 3px solid #ffd600;
    transform: scale(1.05);
    box-shadow: 0 10px 40px rgba(255, 214, 0, 0.4);
    position: relative; /* 메달 위치 기준 */
}

/* 2등 카드 스타일 */
#game-select-scoreboard .rank-2 {
    background: linear-gradient(145deg, #e0e0e0, #bdbdbd);
    border: 3px solid #c5c5c5;
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(197, 197, 197, 0.4);
    position: relative; /* 메달 위치 기준 */
}

/* 메달 스타일 */
.medal {
    position: absolute;
    top: -15px;
    left: -15px;
    font-size: 2.5rem;
    line-height: 1;
}

/* 1등 메달 반짝임 효과 */
.rank-1 .medal {
    animation: sparkle 1.5s infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1); text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #ffc107, 0 0 20px #ffc107; }
    50% { transform: scale(1.2); text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #ffc107, 0 0 40px #ffc107; }
}

#game-select-scoreboard .team-name {
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
}

#game-select-scoreboard .score {
    font-size: 3rem;
    margin-bottom: 0;
}

.team-score-card {
    background: #fff;
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #e9ecef;
}

.team-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.score {
    font-size: 2.5rem;
    font-weight: 700;
    color: #5e72e4;
    margin-bottom: 0;
    line-height: 1;
}

.score-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    align-items: center;
}

.score-controls button {
    font-size: 1.5rem;
    width: 1.8rem;
    height: 1.8rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- 인물 퀴즈 --- */
#quiz-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.image-container {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

#quiz-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 15px;
    /* 드래그 및 선택 방지 */
    user-select: none;
    -webkit-user-drag: none;
}

#quiz-answer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: bold;
    border-radius: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.image-container:active #quiz-answer-overlay,
.image-container:focus #quiz-answer-overlay,
.image-container:hover #quiz-answer-overlay {
    opacity: 1;
}


/* --- 초성 퀴즈 --- */
#chosung-quiz-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

#chosung-question-container {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    font-weight: bold;
    color: #333;
    background: #fff;
    border-radius: 20px;
    user-select: none;
}

#chosung-answer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
    font-weight: bold;
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#chosung-question-container:active #chosung-answer-overlay {
    opacity: 1;
}


/* --- 이어서 말해요 퀴즈 --- */
#continue-quiz-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

#continue-question-container {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem; /* 초성 퀴즈와 동일하게 */
    font-weight: bold;
    color: #333;
    background: #fff;
    border-radius: 20px;
    user-select: none;
}

#continue-answer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem; /* 초성 퀴즈와 동일하게 */
    font-weight: bold;
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#continue-question-container:active #continue-answer-overlay {
    opacity: 1;
}

/* --- 하단 버튼 --- */
.bottom-controls {
    display: flex;
    flex-direction: column; /* 버튼 세로로 배치 */
    gap: 1rem;
    flex-shrink: 0; /* 버튼 영역이 줄어들지 않도록 */
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.bottom-controls .navigation-buttons {
    display: flex;
    gap: 1rem; /* 이전/다음 버튼 사이 간격 */
    width: 100%; /* 부모 너비에 맞춤 */
}

.bottom-controls .navigation-buttons button {
    flex: 1; /* 이전/다음 버튼이 공간을 균등하게 차지 */
}

/* Custom Confirmation Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* 다른 요소 위에 표시 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    background: #fff;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-content p {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 1.5rem;
}

.modal-content .button-group {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.modal-content button {
    flex: 1;
    max-width: 150px;
}

/* 버튼 색상 계층 */
/* 다음 버튼 (가장 강조) */
#next-btn, #chosung-next-btn, #continue-next-btn {
    background: linear-gradient(45deg, #fe6b8b 0%, #ff8e53 100%);
    box-shadow: 0 4px 20px rgba(254, 107, 139, 0.35);
}

/* 뒤로가기 버튼 (중간 강조) */
#back-to-games-btn, #chosung-back-to-games-btn, #continue-back-to-games-btn {
    background: linear-gradient(45deg, #29a1f2, #0277bd);
    box-shadow: 0 4px 20px rgba(41, 161, 242, 0.3);
}

/* 이전 버튼 (강조 안함) */
#prev-btn, #chosung-prev-btn, #continue-prev-btn {
    background: #b0bec5;
    box-shadow: none;
}

#prev-btn:hover, #chosung-prev-btn:hover, #continue-prev-btn:hover {
    background: #90a4ae;
}
