/* 전체 페이지 스타일 */
body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 16px;
    background-color: #f0f8ff;
}

/* 게임 래퍼 스타일: 전체 게임 컨테이너를 감싸는 요소 */
.game-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 게임 스케일러: 화면 크기에 따라 게임 크기를 조절하는 요소 */
.game-scaler {
    position: relative;
    z-index: 1;
}

/* 게임 컨테이너: 실제 게임 내용을 담는 주요 컨테이너 */
.game-container {
    width: 100%;
    height: 100%;
    max-width: 500px;
    max-height: 500px;
    aspect-ratio: 3 / 4;
    margin: auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

/* 게임 화면 스타일: 타이틀, 게임 플레이, 게임 오버 화면에 공통 적용 */
#title-screen,
#game-screen,
#game-over-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

/* 타이틀 화면 스타일 */
#title-screen {
    position: relative;
    justify-content: center;
}

/* 게임 타이틀 스타일 */
#game-title {
    font-size: 1.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-weight: bold;
    color: #3c5aa6;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 1vmin 2vmin;
    border-radius: 10px;
    margin-bottom: 2vmin;
}

/* 이미지 스타일: 타이틀 및 게임 오버 이미지 */
#title-image {
    width: 70%;
    max-height: 70%;
    object-fit: contain;
    margin-bottom: 1vmin;
}

#game-over-image {
    width: 50%;
    max-height: 50%;
    object-fit: contain;
}


/* 버튼 스타일 */
.game-button {
    font-size: clamp(14px, 2vmin, 20px);
    padding: 1vmin 2vmin;
    background-color: #ffd700;
    color: #3c5aa6;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin: 1vmin;
    transition: background-color 0.3s;
    display: inline-block;
    /* 또는 block, 레이아웃에 따라 선택 */
    z-index: 10;
    /* 다른 요소에 가려지지 않도록 */
}

.game-button:hover {
    background-color: #ffed4a;
}

.game-info, .input-control, .game-button {
    font-size: 1rem;
}

/* 게임 정보 스타일: 스코어, 시간 등을 표시하는 영역 */
.game-info {
    width: 100%;
    margin-bottom: 10px;
    padding: 0px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 5px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 5px;
}

.info-item {
    font-size: 1rem;
    /* 1rem은 기본 폰트 크기와 동일 */
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-value {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    color: #3c5aa6;
    min-width: 25px;
    display: inline-block;
    text-align: right;
}

/* 게임 영역 스타일: 실제 게임 플레이가 이루어지는 영역 */
#game-area {
    width: 100%;
    height: 60%;
    min-height: 300px;
    max-height: 400px;
    border: 2px solid #3c5aa6;
    border-radius: 5px;
    position: relative;
    overflow: hidden;
}

/* 포켓몬 단어 스타일 */
.pokemon-word-container {
    position: absolute;
    display: flex;
    align-items: center;
    transition: all 0.5s ease;
    font-size: clamp(0.7rem, 2.2vw, 1.1rem);
    /* 폰트 크기 줄임 */
}

.pokemon-word {
    font-weight: bold;
    margin-right: 5px;
}

.rarity-icon {
    font-size: 0.8em;
}

/* 입력 필드 스타일 */
.input-control {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 90%;
    margin-top: 10px auto;
}

#input-field {
    width: 50%;
    height: 40px;
    flex-grow: 0;
    font-size: 1rem;
    padding: 0px 5px;
    background-color: #fef6aef0;
    border: 2px solid #ffed4a;
    border-radius: 5px 5px 5px 5px;
    outline: none;
}

#nickname-input {
    width: 100%;
    padding: 1vmin;
    font-size: clamp(14px, 1.8vmin, 18px);
    margin-top: 0vmin;
    border: 1px solid #3c5aa6;
    border-radius: 5px;
    box-sizing: border-box;
}

/* 사운드 컨트롤 스타일 */
.sound-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 5px;
    border-radius: 5px;
}

#toggle-sound {
    background: none;
    border: none;
    font-size: 15px;
    color: #3c5aa6;
    cursor: pointer;
    margin: 5px;
}

#toggle-sound,
#volume-control {
    z-index: 10000;
}

#volume-control {
    width: 70px;
}

/* Font Awesome 아이콘을 위한 스타일 */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css');

/* 게임 오버 화면 스타일 */
#game-over-screen {
    text-align: center;
}

#final-score {
    font-size: clamp(20px, 2vmin, 24px);
    font-weight: bold;
    margin: 1vmin 0;
    color: #3c5aa6;
}

#game-stats {
    text-align: left;
    margin: 1vmin 0;
}

#game-stats p {
    margin: 0vmin 0;
    padding-left: 3vmin;
    background: url('../images/pokeball.png') no-repeat left center;
    background-size: 2.4vmin;
    line-height: 1.5;
    font-size: clamp(14px, 1.6vmin, 16px);
}

.input-group {
    display: flex;
    align-items: center;
    margin: 0vmin 0;
}

#nickname-input {
    flex-grow: 1;
    margin-right: 0vmin;
    height: 5vmin;
}

#register-and-show-ranking {
    background-color: #ff4d4d;
    color: white;
    padding: 0 2vmin;
    height: 5vmin;
    white-space: nowrap;
}

#register-and-show-ranking:hover {
    background-color: #ff3333;
}

#show-pokedex {
    background-color: #3c5aa6;
    color: white;
}

#show-pokedex:hover {
    background-color: #4c6ab6;
}

/* 모달 스타일 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 10px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#rankings-modal h2,
#pokedex-modal h2 {
    color: #3c5aa6;
}

/* 포켓몬 도감 스타일 */
#pokedex-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
}

.pokemon-entry {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    text-align: center;
}

.captured {
    background-color: #e8f5e9;
}

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

#prev-page,
#next-page {
    padding: 5px 10px;
    background-color: #3c5aa6;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#prev-page:disabled,
#next-page:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* 체력바 스타일 */
.health-container {
    width: 100%;
    height: 20px;
    background-color: #ddd;
    border-radius: 10px;
    margin-top: 5px;
    grid-column: 1 / span 3;
    position: relative;
}

#health-bar {
    width: 100%;
    height: 100%;
    background-color: #4CAF50;
    border-radius: 10px;
    transition: width 0.3s ease-in-out;
}

#health-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    font-size: clamp(12px, 1.6vmin, 16px);
    z-index: 1;
    /* 추가 */
}

/* 저작권 표시 스타일 */
.copyright {
    position: fixed;
    bottom: 1vmin;
    left: 0;
    right: 0;
    text-align: center;
    font-size: clamp(10px, 1.4vmin, 14px);
    color: #3c5aa6;
    z-index: 100; /* z-index 추가 */
}

/* 숫자 변경 애니메이션 */
@keyframes numberChange {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.number-changed {
    animation: numberChange 0.3s ease-in-out;
}

@keyframes appear {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: rotate(0deg);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: rotate(-10deg);
    }

    20%,
    40%,
    60%,
    80% {
        transform: rotate(10deg);
    }
}

@keyframes disappear {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* 포켓볼 애니메이션 */
.pokeball {
    position: absolute !important;
    width: 60px;
    height: 60px;
    background-image: url('../images/pokeball.png');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 1000 !important;
    transform-origin: center center;
    will-change: transform, opacity;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    /* pointer-events: none !important; */

    animation: appear 0.1s ease-out,
        shake 0.5s ease-in-out 0.1s 1,
        disappear 0.1s ease-in 0.6s forwards;
}

.pokeball.catching {
    animation: catch 2s ease-in-out forwards;
}

/* 콤보 효과 */
.combo-effect {
    position: absolute;
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 1000;
}

/* 특별 포켓몬 효과 */
.special-pokemon {
    animation: golden-sparkle 1s infinite alternate;
}

@keyframes golden-sparkle {
    0% {
        text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #ffd700, 0 0 35px #ffd700, 0 0 40px #ffd700, 0 0 50px #ffd700, 0 0 75px #ffd700;
    }

    100% {
        text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #ffd700, 0 0 70px #ffd700, 0 0 80px #ffd700, 0 0 100px #ffd700, 0 0 150px #ffd700;
    }
}

/* 아이템 효과 스타일 */
.item-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: fadeInOut 2s ease-in-out;
    z-index: 1000;
}

@keyframes fadeInOut {

    0%,
    100% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }
}

/* 스테이지 클리어 팝업 스타일 */
.stage-clear-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    width: 80%;
    max-width: 400px;
    text-align: center;
}

.stage-clear-popup h2 {
    color: #3c5aa6;
    margin-bottom: 15px;
}

.stage-clear-popup p {
    font-size: 18px;
    line-height: 1.5;
    margin: 5px 0;
}

.stage-clear-popup img {
    width: 18px;
    vertical-align: middle;
    margin-right: 10px;
}

.stage-clear-popup .stage-stats {
    text-align: left;
    margin-bottom: 20px;
}

.stage-clear-popup .game-button {
    margin-top: 15px;
    padding: 10px 20px;
    font-size: 16px;
    background-color: #ffcb05;
    color: #3c5aa6;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.stage-clear-popup .game-button:hover {
    background-color: #ffd740;
}

.stage-stats {
    text-align: left;
    margin-bottom: 20px;
}

.stage-stats p {
    text-align: left;
    margin: 5px 0;
}

.stage-stats p::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background-image: ('images/pokeball.png');
    background-size: contain;
    background-repeat: no-repeat;
}

.stat-icon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    vertical-align: middle;
}

/* 모바일 환경을 위한 반응형 스타일 */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .game-wrapper {
        width: 100%;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .game-scaler {
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .game-container {
        width: 95vw;
        height: 95vh;
        max-width: 400px;
        max-height: 600px;
        aspect-ratio: 2 / 3;
        margin: auto;
        padding: 10px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    #game-area {
        width: 100%;
        height: 60%;
        min-height: 200px;
        max-height: 350px;
        margin-bottom: 10px;
    }

    .game-info {
        font-size: 0.8rem;
    }

    .info-grid {
        grid-template-columns: 1fr 1fr;
        gap: 5px;
    }

    .input-control {
        width: 100%;
        margin: 5px 0;
    }

    #input-field {
        width: 50%;
        height: 30px;
        font-size: 0.9rem;
    }

    .game-button {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }

    .stage-clear-popup {
        width: 90%;
        padding: 15px;
    }

    .stage-clear-popup h2 {
        font-size: 1.2rem;
    }

    .stage-clear-popup p {
        font-size: 0.9rem;
    }

    .copyright {
        font-size: 0.7rem;
    }
}

/* 랭킹 테이블 스타일 */
.rankings-table-container {
    overflow-y: auto;
    max-height: calc(80vh - 100px);
}

.rankings-list {
    max-height: 80vh;
    overflow-y: auto;
}

.rank-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.rank-item:hover {
    background-color: #f5f5f5;
}

.current-rank {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #fff;
    font-weight: bold;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    animation: highlight 2s infinite;
}

.rank-number {
    width: 30px;
    font-weight: bold;
}

.rank-nickname {
    flex-grow: 1;
    margin-right: 10px;
}

.rank-score {
    font-weight: bold;
    margin-right: 10px;
}

.rank-stage,
.rank-completion {
    margin-left: 10px;
    font-size: 0.9em;
}

/* 랭킹 하이라이트 애니메이션 */
@keyframes highlight {
    from {
        background-color: #fffde7;
    }

    to {
        background-color: #fff9c4;
    }
}

.current-rank {
    animation: highlight 2s infinite;
}

.rankings-container {
    max-height: calc(80vh - 60px);
    overflow-y: auto;
}

/* 랭킹 테이블 스타일 */
.rankings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px
}

.rankings-table thead {
    position: sticky;
    top: 0;
    background-color: #f2f2f2;
    z-index: 1;
}

.rankings-table th,
.rankings-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.rankings-table th {
    font-weight: bold;
    white-space: nowrap;
}

.rankings-table tbody tr:nth-child(even) {
    background-color: #f8f8f8;
}

.rankings-table .current-user {
    background-color: #fffde7;
    font-weight: bold;
}

.modal-content {
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.copyright a {
    color: #3c5aa6;
    text-decoration: none;
    transition: color 0.3s ease;
    cursor: pointer; /* 커서 스타일 추가 */
    padding: 5px 10px; /* 클릭 영역 확장 */
}

.copyright a:hover {
    color: #ffcb05;
    text-decoration: underlineㅍ;
}