/* 기본 스타일 및 폰트 */
body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #f0f8ff;
    font-family: 'Press Start 2P', cursive;
    color: #333;
}

#game-container {
    width: 90%;
    max-width: 500px;
    padding: 20px;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    text-align: center;
    overflow: hidden;
}

/* 화면 전환 관리 */
.screen {
    display: none;
}
.screen.active {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* 요소별 스타일 */
h1, h2, h3 {
    color: #333;
}

p {
    color: #666;
    line-height: 1.6;
    font-size: 0.8em;
}

button {
    background-color: #4CAF50;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-family: 'Press Start 2P', cursive;
    transition: background-color 0.3s;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

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

#restart-button {
    background-color: #008CBA;
}
#restart-button:hover {
    background-color: #007ba7;
}

input[type="number"], input[type="text"] {
    padding: 10px;
    width: 80%;
    border: 2px solid #ccc;
    border-radius: 8px;
    font-size: 1em;
    text-align: center;
    font-family: 'Press Start 2P', cursive;
}

input:focus {
    outline: 2px solid #4CAF50;
}

#start-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
}

/* ▼▼▼ 이 부분의 스타일이 변경되었습니다 ▼▼▼ */
.character-img {
    max-width: 350px; /* 기존 150px -> 350px 로 약 2.3배 증가 */
    margin: 20px 0;
    animation: float 3s ease-in-out infinite;
    image-rendering: pixelated; /* 픽셀 아트 느낌 살리기 */
}

.character-img.small {
    max-width: 160px; /* 기존 80px -> 160px 로 2배 증가 */
    margin: 0 0 20px 0; /* 이미지와 문제 사이의 간격을 위해 아래쪽 마진 추가 */
}
/* ▲▲▲ 이 부분의 스타일이 변경되었습니다 ▲▲▲ */


@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

/* 게임 플레이 화면 스타일 */
#game-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 1em;
}

#timer-bar-container {
    width: 100%;
    height: 20px;
    background-color: #e0e0e0;
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
}

#timer-bar {
    height: 100%;
    width: 100%;
    background-color: #4CAF50;
    border-radius: 10px;
    transition: width 1s linear, background-color 0.5s;
}

#problem-area {
    display: flex;
    flex-direction: column; /* 자식 요소들을 세로로 쌓음 */
    align-items: center;   /* 가운데 정렬 */
    justify-content: center;
    margin: 20px 0 30px 0; /* 위아래 여백 조정 */
    min-height: 120px; /* 문제 영역의 최소 높이를 확보하여 레이아웃이 출렁이는 것을 방지 */
}

#problem {
    font-size: 2em;
    font-weight: bold;
    color: #333;
    line-height: 1.4; /* 줄바꿈 시 줄 간격을 적절하게 조정 */
    word-break: break-all; /* 단어 단위가 아닌 글자 단위로 줄바꿈하여 공간을 최대한 활용 */
}

/* 정답/오답 애니메이션 */
.correct {
    animation: correct-pulse 0.5s;
}

@keyframes correct-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.shake {
    animation: shake 0.5s;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}


/* 리더보드 스타일 추가 */
#leaderboard {
    margin-top: 30px;
    text-align: left;
    max-height: 200px;
    overflow-y: auto;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px;
}

#leaderboard h3 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2em;
}

#ranking-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#ranking-list li {
    padding: 8px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
}

#ranking-list li:last-child {
    border-bottom: none;
}

#ranking-list .rank-name {
    font-weight: bold;
}
#ranking-list .rank-score {
    color: #333;
}
