/* 기존 스타일 유지 */
@import url('https://fonts.googleapis.com/css2?family=Dongle:wght@300&family=Gamja+Flower&family=Gowun+Dodum&display=swap');

body {
    font-family: "Gowun Dodum", sans-serif;
    background-color: #f0f0f0;
    margin: 0;
    padding: 0;
    text-align: center;
}

.screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

#start-screen {
    /* 배경 이미지 설정 */
    background-image: url('images/pixelbg.webp'); /* 이미지 경로를 실제 경로로 변경하세요 */
    background-size: cover; /* 이미지를 화면에 꽉 채우기 */
    background-position: center; /* 이미지를 중앙에 위치 */
    background-repeat: no-repeat; /* 이미지 반복 방지 */
    position: relative; /* 오버레이를 위한 위치 설정 */
}

/* 오버레이 추가 (선택 사항) */
#start-screen::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* 반투명 검정색 오버레이 */
    z-index: 1;
}

.game-container {
    position: relative; /* 오버레이 위에 표시되도록 */
    z-index: 2; /* 오버레이보다 위에 표시 */
    max-width: 800px;
    width: 90%;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.8); /* 반투명 흰색 배경 */
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

h1 {
    margin-bottom: 20px;
    color: #333; /* 텍스트 색상 조정 */
}

.start-button, .submit-button, .next-button, .restart-button, .initial-button {
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
    margin: 5px;
    border: none;
    border-radius: 5px;
    background-color: #4caf50;
    color: #fff;
    transition: background-color 0.3s;
}

.start-button:hover, .submit-button:hover, .next-button:hover, .restart-button:hover, .initial-button:hover {
    background-color: #45a049;
}

.initial-button {
    background-color: #2196F3;
}

.initial-button:hover {
    background-color: #1976D2;
}

.problem-counter {
    font-size: 1.2em;
    margin-bottom: 5px;
    margin-top: 15px;
}

.timer {
    font-size: 1.2em;
    margin-bottom: 5px;
    margin-top: 15px;
}

.top-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.main-content {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}

.target-number {
    display: grid;
    grid-template-columns: repeat(3, 10px);
    grid-template-rows: repeat(5, 10px);
    gap: 3px;
}

.target-number .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #e0e0e0;
}

.target-number .dot.active {
    background-color: #e65272;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 60px);
    grid-template-rows: repeat(5, 60px);
    gap: 5px;
    justify-content: center;
    margin: 0 auto;
}

.cell {
    width: 60px;
    height: 60px;
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    position: relative;
    transition: background-color 0.3s;
}

.cell.active {
    background-color: #4caf50;
}

.options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.option {
    padding: 5px;
    background-color: #f9f9f9;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    position: relative;
}

.option.selected {
    background-color: #e6e6e6;
}

.option:hover {
    background-color: #e6e6e6;
}

.option .option-grid {
    display: grid;
    grid-template-columns: repeat(3, 8px);
    grid-template-rows: repeat(5, 8px);
    gap: 1px;
    margin-top: 5px;
}

.option .option-cell {
    width: 8px;
    height: 8px;
    background-color: #e0e0e0;
}

.option .option-cell.active {
    background-color: #4caf50;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.message {
    margin-top: 20px;
    font-size: 1.1em;
    color: #333;
}

.results {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-item .grid {
    grid-template-columns: repeat(3, 20px);
    grid-template-rows: repeat(5, 20px);
    gap: 2px;
}

.total-time {
    font-size: 1.2em;
    margin-top: 20px;
}

/* 버튼 한 줄로 표시 */
.controls {
    flex-wrap: nowrap;
}

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

/* 팝업 스타일 */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5); /* 반투명 검정색 배경 */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* 다른 요소들보다 위에 표시 */
}

.popup-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    position: relative;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5em;
    cursor: pointer;
}

#player-name {
    width: 80%;
    padding: 10px;
    margin: 15px 0;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.submit-name-button {
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #4caf50;
    color: #fff;
    transition: background-color 0.3s;
}

.submit-name-button:hover {
    background-color: #45a049;
}

/* Leaderboard 테이블 스타일 */
#leaderboard {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

#leaderboard th, #leaderboard td {
    padding: 10px;
    border: 1px solid #ccc;
    text-align: center;
}

#leaderboard th {
    background-color: #f2f2f2;
}

#leaderboard tr:nth-child(even) {
    background-color: #f9f9f9;
}
/* 광고 컨테이너 스타일 */
.adsense-container {
    width: 100%;
    max-width: 728px; /* 광고 최대 너비 설정 */
    margin: 10px auto; /* 중앙 정렬 및 상하 마진 설정 */
}

@media (min-width: 1024px) {
    .adsense-container {
        position: fixed; /* 화면 오른쪽에 고정 */
        top: 0;
        right: 0; /* 화면 오른쪽 여백 */
        width: 300px; /* 광고의 너비 */
        height: 100vh; /* 화면 전체 높이에 맞춤 */
        background-color: #f9f9f9; /* 배경색 설정 (필요 시) */
        box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1); /* 그림자 효과 추가 */
        z-index: 1000; /* 다른 요소보다 위에 표시 */
    }
    body {
        margin-right: 300px; /* 광고 공간 확보 */
    }
}

/* 반응형 디자인 유지 */
@media (max-width: 768px) {
    .grid {
        grid-template-columns: repeat(3, 40px);
        grid-template-rows: repeat(5, 40px);
    }

    .cell {
        width: 40px;
        height: 40px;
    }

    .option .option-grid {
        grid-template-columns: repeat(3, 5px);
        grid-template-rows: repeat(5, 5px);
    }

    .option .option-cell {
        width: 5px;
        height: 5px;
    }

    .option {
        padding: 5px;
    }

    .main-content {
        flex-direction: row;
        align-items: flex-start;
    }

    .target-number {
        grid-template-columns: repeat(3, 5px);
        grid-template-rows: repeat(5, 5px);
    }

    .target-number .dot {
        width: 5px;
        height: 5px;
    }

    .controls {
        flex-direction: row;
        justify-content: center;
    }

    .submit-button, .initial-button {
        width: 45%; /* 버튼 너비 조정 */
        padding: 8px 0;
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    .adsense-container {
        max-width: 100%; /* 모바일에서는 전체 너비 사용 */
    }
    .game-container {
        min-height: 80vh; /* 화면의 90% 높이 */
    }
    .grid {
        grid-template-columns: repeat(3, 20px);
        grid-template-rows: repeat(5, 20px);
    }

    .cell {
        width: 20px;
        height: 20px;
    }

    .option {
        height: 10vh; /* 작은 화면에서는 조금 더 크도록 설정 */
        padding: 1vh; /* 내부 여백 증가 */
        font-size: 0.9em; /* 폰트 크기 약간 줄임 */
    }

    .option .option-grid {
        grid-template-columns: repeat(3, 10px); /* 내부 셀 크기 증가 */
        grid-template-rows: repeat(5, 10px);
    }

    .option .option-cell {
        width: 10px;
        height: 10px;
    }

    .main-content {
        flex-direction: column;
        align-items: center;
    }

    .target-number {
        grid-template-columns: repeat(3, 5px);
        grid-template-rows: repeat(5, 5px);
    }

    .target-number .dot {
        width: 5px;
        height: 5px;
    }
    .controls {
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        margin-top: 20px; /* 버튼들을 아래로 내리기 */
    }

    .submit-button, .initial-button {
        width: 45%; /* 버튼 너비 조정 */
        padding: 8px 0;
        font-size: 0.9em;
    }

    .problem-counter, .timer, .target-number {
        font-size: 1em;
    }

    .total-time {
        font-size: 1em;
    }
}
