/* 전체 페이지 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #2d1810 0%, #1a0f08 100%);
    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: start;
    min-height: 100vh;
    color: #fff;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center; /* 수평 중앙 정렬 */
    justify-content: flex-start; /* 수직 상단 정렬 */
    width: 100%;
    max-width: 640px;
    height: 100%;
    background: linear-gradient(135deg, #2d1810 0%, #1a0f08 100%);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* 상단 UI */
.top-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: start;
    align-items: start;
    padding: 15px 20px;
    z-index: 10;
    pointer-events: none; /* 클릭 이벤트가 캔버스로 전달되도록 */
}

.top-ui > * {
    pointer-events: auto; /* 내부 요소들은 클릭 가능하게 */
}

.score-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-label {
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.score-value {
    font-size: 20px;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}



/* 게임 캔버스 */
#gameCanvas {
    width: 640px;
    height: 900px;
    max-width: 100%;
    margin: 0 auto; /* 수평 중앙만, 수직은 상단에 고정 */
    display: block;
    background: url('bg.png') no-repeat 0 0;
    background-size: cover;
    touch-action: none;
    cursor: grab;
}

#gameCanvas:active {
    cursor: grabbing;
}

/* 하단 UI */
.bottom-ui {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
}

.game-buttons {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 15px;
}

.ui-button {
    padding: 10px 16px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.login-btn {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
}

.ranking-btn {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #333;
}



.ui-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.ui-button:active {
    transform: translateY(0);
}

.instructions {
    text-align: center;
}

.instructions p {
    font-size: 18px;
    color: #fff;
    margin: 3px 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* 모달 공통 스타일 */
.login-modal, .ranking-modal, .story-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.login-modal-content, .ranking-modal-content, .story-modal-content {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    border-radius: 20px;
    max-width: 90%;
    width: 400px;
    max-height: 85vh;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s ease;
}

.login-modal.show .login-modal-content,
.ranking-modal.show .ranking-modal-content,
.story-modal.show .story-modal-content {
    transform: scale(1);
    opacity: 1;
}

/* 로그인 모달 */
.login-modal-content {
    padding: 30px;
}

.login-modal-content h2 {
    color: #fff;
    margin-bottom: 10px;
    font-size: 24px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.login-modal-content p {
    color: #ccc;
    margin-bottom: 25px;
    font-size: 16px;
    line-height: 1.4;
}

.name-list-container {
    max-height: 400px;
    overflow-y: auto;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 0;
}

.name-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.name-item {
    padding: 15px 20px;
    margin: 0 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 24px;
    font-weight: 500;
    text-align: center;
}

.name-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
}

.name-item:active {
    transform: translateY(0);
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.5);
}

/* 랭킹 모달 */
.ranking-modal-content {
    display: flex;
    flex-direction: column;
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ranking-header h2 {
    color: #fff;
    margin: 0;
    font-size: 24px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.close-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 35px;
    height: 35px;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.ranking-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 30px;
    max-height: 60vh;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.ranking-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(5px);
}

.ranking-item.current-user {
    background: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.4);
}

.rank-number {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    min-width: 40px;
    text-align: center;
}

.rank-number.top-3 {
    color: #ffd700;
}

.rank-number.rank-1::before { content: '🥇 '; }
.rank-number.rank-2::before { content: '🥈 '; }
.rank-number.rank-3::before { content: '🥉 '; }

.user-info {
    flex: 1;
    margin-left: 15px;
}

.user-name-rank {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 2px;
}

.user-date {
    font-size: 12px;
    color: #ccc;
}

.user-score {
    font-size: 18px;
    font-weight: bold;
    color: #4ecdc4;
    min-width: 80px;
    text-align: right;
}

.loading-message, .empty-ranking {
    text-align: center;
    color: #ccc;
    padding: 40px 0;
    font-size: 16px;
}

/* 스토리 모달 */
.story-modal-content {
    padding: 40px 30px;
    max-width: 500px;
}

.story-content {
    margin-bottom: 30px;
}

.story-title {
    font-size: 28px;
    font-weight: bold;
    color: #FFD700;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.story-text {
    font-size: 16px;
    line-height: 1.6;
    color: #fff;
    margin-bottom: 15px;
    text-align: left;
}

.story-score {
    font-size: 24px;
    font-weight: bold;
    color: #4ecdc4;
    text-align: center;
    margin: 20px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.continue-button {
    padding: 15px 30px;
    background: linear-gradient(45deg, #4CAF50, #45a049);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.continue-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.continue-button:active {
    transform: translateY(0);
}

/* 스크롤바 스타일링 */
.name-list-container::-webkit-scrollbar,
.ranking-list-container::-webkit-scrollbar {
    width: 6px;
}

.name-list-container::-webkit-scrollbar-track,
.ranking-list-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.name-list-container::-webkit-scrollbar-thumb,
.ranking-list-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.name-list-container::-webkit-scrollbar-thumb:hover,
.ranking-list-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* 모바일 최적화 */
@media (max-width: 480px) {
    body {
        min-height: 100vh;
    }
    
    .game-container {
        max-width: 100%;
        height: 100vh;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
    }
    
    .top-ui {
        padding: 8px 15px;
    }
    
    .score-label, .score-value {
        font-size: 14px;
    }
    
    .ui-button {
        padding: 8px 12px;
    }
    
    .instructions p {
        font-size: 13px;
        margin: 2px 0;
    }
    
    .bottom-ui {
        padding: 10px 15px;
    }
    
    .login-modal-content, .ranking-modal-content, .story-modal-content {
        width: 95%;
        max-width: 350px;
    }
    
    .name-item {
        font-size: 20px;
        padding: 12px 15px;
    }
} 