
/* 기본 스타일 초기화 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: Arial, sans-serif;
    background: #121212;
    color: #ffffff;
}

/* 게임 컨테이너 */
.game-container {
    width: 100%;
    height: 100vh;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* 화면 공통 스타일 */
.screen {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #121212;
}

.screen.active {
    display: flex;
}

/* 시작 화면 */
#start-screen {
    position: relative;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* 제시한 이미지 URL 사용 */
    background: url('https://i.ibb.co/m5x4PhV/88-A780-C7-A4-D5-48-C9-A080-B859-E482091-A.png') no-repeat center center;
    background-size: cover;
}

#start-screen .game-title,
#start-screen .btn {
    z-index: 2; /* 오버레이 위로 올리기 */
}

/* 타이틀 스타일링 */
.game-title {
    font-size: clamp(2rem, 5vw, 4rem);
    color: #ffffff;
    margin-bottom: 3rem;
    font-weight: 800;
    letter-spacing: 8px;
    text-align: center;
    text-transform: uppercase;
    text-shadow: 
        2px 2px 0 #000,
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        0 0 20px rgba(0,0,0,0.5);
    animation: titleFloat 3s ease-in-out infinite;
    position: relative;
}

/* 타이틀 호버 효과 */
.game-title:hover {
    transform: scale(1.02);
    transition: transform 0.3s ease;
}

/* 버튼 스타일링 */
.btn {
    background: linear-gradient(45deg, #1e88e5, #1565c0);
    color: #ffffff;
    padding: 0.4rem 2.0rem;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 8px;
    margin-top: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* 버튼 호버 효과 */
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
    background: linear-gradient(45deg, #1976d2, #1565c0);
}

/* 버튼 활성화 효과 */
.btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 버튼 물결 효과 */
.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 300px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.6s, opacity 0.6s;
}

.btn:hover::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* 타이틀 플로팅 애니메이션 */
@keyframes titleFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* 설정 화면 */
#settings-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
    width: 100%;
}

.settings-wrapper {
    align-items: center;
    background: #1e1e1e;
    padding: 20px;
    border-radius: 10px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.setting-group {
    margin-bottom: 1.5rem;
    text-align: center;
}

.setting-group label {
    display: block;
    margin-bottom: 5px;
    color: #ccc;
    font-size: 1rem;
}

.setting-group select,
.setting-group input {
    width: 100%;
    padding: 10px;
    background: #333;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 1rem;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 5vh;
}

button#start-game-button {
    background: #1e88e5;
    color: white;
    padding: 0.4rem 2rem;
    border: none;
    cursor: pointer;
    font-size: 2rem;
    border-radius: 5px;
    margin-top: 0.5rem;
    transition: background 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

button#start-game-button:hover {
    background: #1565c0;
}

/* 게임 화면 */
#game-screen {
    padding: 2rem;
}

.info-panel {
    display: flex;
    justify-content: space-between;
    width: 95%;
    max-width: 600px;
    margin-bottom: 0.1rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 8px;
}

.hearts, .timer {
    font-size: 1.5rem;
}

.round-info {
    display: flex;
    flex-direction: column;
    align-items: center; /* 중앙 정렬 */
    font-size: 1.2rem;
    font-weight: bold; /* 볼드체 적용 */
    color: #fff;
    text-align: center;
}

.score-panel {
    display: flex;
    justify-content: flex-end; /* 좌우로 간격 조정 */
    align-items: center; /* 세로 가운데 정렬 */
    gap: 1rem; /* 두 점수 사이 간격 */
    font-size: 1.5rem; /* 점수 크기 조정 */
}

.board-container {
    width: 95%;
    max-width: 600px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    box-sizing: border-box;
}

.board-container::before {
    content: '';
    display: block;
    padding-top: 10%;
}

#game-board {
    display: grid;
    gap: 5px;
    width: 100%;
    height: 100%;
    background: #333;
    padding: 10px;
    border-radius: 8px;
    box-sizing: border-box;
}

.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #444;
    color: white;
    cursor: pointer;
    border-radius: 4px;
    user-select: none;
    transition: all 0.3s ease;
    /* font-size: 제거 혹은 매우 작은 값으로 */
}

.cell:hover {
    background: #555;
    transform: scale(1.05);
}

/* 게임 오버 화면 */
#gameover-screen {
    background: rgba(0, 0, 0, 0.95);
    padding: 10px;
}

.gameover-content {
    max-height: 95vh;
    overflow-y: auto;
    padding: 2rem;
    border-radius: 10px;
    width: 100%;
    max-width: 500px;
    text-align: center;
    background: #1e1e1e;
}

.gameover-content h2 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

.final-score {
    font-size: 1.5rem;
    margin: 1.5rem 0;
    color: #1e88e5;
}

.no-scores {
    text-align: center;
    padding: 1rem;
    color: #888;
}

.name-input-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.dialog-content {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    max-width: 80%;
    width: 300px;
}

.dialog-content h2 {
    margin-top: 0;
    color: #333;
}

.dialog-content input {
    width: 100%;
    padding: 8px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.dialog-content button {
    padding: 8px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.dialog-content button:hover {
    background-color: #45a049;
}

.high-scores-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    max-height: 300px;
    overflow-y: auto;
}

.high-score-item {
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
    padding: 12px;
    border-radius: 8px;
}

.score-header {
    display: grid;
    grid-template-columns: 1fr 100px 1fr;
    align-items: center;
    margin-bottom: 8px;
}

.rank {
    color: gold;
    font-weight: bold;
    justify-self: start;
}

.score {
    color: #00ff00;
    font-weight: bold;
    font-size: 1.2em;
    justify-self: center;
    grid-column: 2;
}

.name {
    justify-self: end;
    color: #fff;
    font-weight: bold;
}

.score-details {
    display: flex;
    gap: 10px;
    color: #888;
    font-size: 0.9em;
}

.mode {
    color: #888;
}

.score-date {
    font-size: 0.8em;
    color: #666;
    text-align: right;
}

.mode-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.mode-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mode-btn.selected {
    background: #4CAF50;
    font-weight: bold;
}

/* 애니메이션 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.screen.active {
    animation: fadeIn 0.3s ease-in-out;
}

/* 유틸리티 클래스 */
.hidden {
    display: none !important;
}

/* 셀 상태 스타일 */
.cell.prime {
    background-color: #0066cc;
}

.cell.composite {
    background-color: #cc0000;
}

/* 컨트롤 패널 */
.control-panel {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* 포커스 효과 */
button:focus, 
select:focus, 
input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.5);
}

/* 접근성 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

.password-dialog, .confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.dialog-content {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    color: #000;
}

.dialog-content input {
    margin: 10px 0;
    padding: 5px;
    width: 200px;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.error-message {
    color: #ff0000;
    margin-top: 10px;
}

.success-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #4CAF50;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1200;
}

/* 게임 화면 내의 보드 테두리 스타일과 점수 패널 스타일 */
/* RED 플레이어 스타일 */
#game-screen div.board-container div#game-board.player-a-turn {
    border: 5px solid #ff4444 !important;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
}

/* BLUE 플레이어 스타일 */
#game-screen div.board-container div#game-board.player-b-turn {
    border: 5px solid #4444ff !important;
    box-shadow: 0 0 10px rgba(68, 68, 255, 0.5);
}

/* 점수 패널 스타일 - 더 구체적인 선택자 사용 */
#game-screen .info-panel .score-panel div#player-a-score {
    color: #ff4444 !important;
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 68, 68, 0.3);
}

#game-screen .info-panel .score-panel div#player-b-score {
    color: #4444ff !important;
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(68, 68, 255, 0.3);
}

#game-screen .info-panel .single-score-container div#score {
    color: #ff4444 !important;
    font-weight: bold;
    font-size: 1.5em;
    text-shadow: 0 0 5px rgba(255, 68, 68, 0.3);
    justify-content: flex-end;
}

.timer-bar-container {
    width: 95%; /* info-panel과 같은 가로 너비 */
    max-width: 600px; /* 게임판과 동일한 최대 너비 */
    height: 10px; /* 타이머 바 높이 */
    background-color: #444; /* 배경색 */
    border-radius: 5px;
    margin: 10px auto; /* 위아래 간격 */
    position: relative;
    overflow: hidden;
}

.timer-bar {
    width: 100%; /* 초기 너비 */
    height: 100%; /* 전체 높이 */
    background-color: white; /* 초기 흰색 */
    transition: width 1s linear, background-color 0.3s ease; /* 너비와 색상 전환 효과 */
    border-radius: 5px;
}

.battle-result {
    font-size: 2.5rem; /* 결과 텍스트 크기 */
    font-weight: bold; /* 볼드체 */
    text-align: center; /* 중앙 정렬 */
    margin: 1rem 0; /* 위아래 여백 */
}

.battle-result.red-wins {
    color: #ff4444;
    font-weight: bold;
}

.battle-result.blue-wins {
    color: #4444ff;
    font-weight: bold;
}

.battle-result.draw {
    color: #888;
    font-weight: bold;
}

.red-score {
    color: #ff4444;
    font-weight: bold;
    font-size: 3rem;
}

.blue-score {
    color: #4444ff;
    font-weight: bold;
    font-size: 3rem;
}

