/* 전역 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', 'Roboto', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 화면 전환 */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 로딩 화면 */
.loading {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 메인 메뉴 */
.menu-container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.game-title {
    font-size: 2.5rem;
    color: #667eea;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 버튼 스타일 */
.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #ffb300;
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
}

.btn-info:hover {
    background: linear-gradient(135deg, #138496 0%, #117a8b 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(23, 162, 184, 0.4);
}

.btn-icon {
    padding: 10px 15px;
    font-size: 1.2rem;
    min-width: 45px;
}

.btn-disabled {
    background: #ccc;
    color: #999;
    cursor: not-allowed;
}

.btn-disabled:hover {
    transform: none;
}

/* 레벨 선택 */
.level-input-container {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.level-input-container label {
    display: block;
    font-weight: 500;
    margin-bottom: 10px;
    color: #333;
}

.level-input-group {
    display: flex;
    gap: 10px;
}

.level-input-group input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.level-input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.level-input-group button {
    padding: 12px 30px;
    white-space: nowrap;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    margin: 30px 0;
    max-height: 400px;
    overflow-y: auto;
}

.level-btn {
    padding: 8px;
    border: 2px solid #667eea;
    border-radius: 10px;
    background: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 70px;
}

.level-num {
    font-size: 1.3rem;
    font-weight: bold;
}

.level-record {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    font-size: 0.7rem;
    line-height: 1.2;
    opacity: 0.9;
}

.level-record small {
    font-weight: normal;
}

.level-btn.unlocked {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.level-btn.unlocked:hover {
    transform: scale(1.05);
}

/* 퍼펙트 클리어 (금색) */
.level-btn.perfect {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 50%, #ffd700 100%);
    color: #333;
    border-color: #ffb700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.level-btn.perfect:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

.level-btn.locked {
    background: #f0f0f0;
    color: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}

/* 게임 화면 */
.game-container {
    max-width: 800px;
    width: 100%;
}

.game-header {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.game-stats {
    display: flex;
    gap: 30px;
}

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

.stat-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.game-actions {
    display: flex;
    gap: 10px;
}

/* 게임 보드 */
.game-board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: clamp(4px, 1.5vw, 12px);
    margin-bottom: 30px;
    padding: clamp(10px, 3vw, 20px);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    max-width: 900px;
    width: 95%;
    margin-left: auto;
    margin-right: auto;
}

.bottle {
    aspect-ratio: 1 / 2.5;
    background: linear-gradient(to bottom, rgba(255,255,255,0.3), rgba(255,255,255,0.1));
    border: clamp(1px, 0.3vw, 3px) solid #333;
    border-radius: 0 0 clamp(10px, 2vw, 15px) clamp(10px, 2vw, 15px);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    width: 100%;
    max-width: 80px;
    margin: 0 auto;
}

.bottle:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.bottle.selected {
    border-color: #ffc107;
    border-width: 4px;
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.6);
}

.water-layer {
    width: 100%;
    transition: all 0.5s ease;
    border-top: 1px solid rgba(255,255,255,0.3);
}

.water-layer.empty {
    background: transparent;
}

/* 게임 컨트롤 */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.score-display {
    background: white;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    display: flex;
    justify-content: space-around;
    font-size: 1.1rem;
}

.score-display div {
    display: flex;
    flex-direction: column;
}

.score-display span {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
    margin-top: 5px;
}

/* 하이라이트 */
.highlight {
    color: #ffc107;
    font-weight: bold;
    font-size: 1.2em;
}

/* 상점 */
.shop-container {
    max-width: 600px;
}

.shop-header {
    font-size: 1.2rem;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.shop-items {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.shop-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.shop-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.item-icon {
    font-size: 3rem;
}

.item-info {
    flex: 1;
    text-align: left;
}

.item-info h3 {
    margin-bottom: 5px;
    color: #333;
}

.item-info p {
    color: #666;
    font-size: 0.9rem;
}

.item-price {
    font-weight: bold;
    color: #667eea !important;
    margin-top: 5px !important;
}

/* 게임 방법 */
.how-to-play-content {
    text-align: left;
    max-height: 500px;
    overflow-y: auto;
    padding: 20px;
}

.how-to-play-content h3 {
    color: #667eea;
    margin-top: 20px;
    margin-bottom: 10px;
}

.how-to-play-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.how-to-play-content li {
    margin-bottom: 8px;
    line-height: 1.6;
}

/* 모달 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 20px;
}

/* 퀴즈 */
.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.btn-quiz-option {
    padding: 15px;
    border: 2px solid #667eea;
    border-radius: 10px;
    background: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-quiz-option:hover {
    background: #667eea;
    color: white;
}

.quiz-note {
    color: #ffc107;
    font-weight: bold;
    margin-top: 10px;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .game-board {
        width: 98%;
    }

    .game-header {
        flex-direction: column;
        gap: 15px;
    }

    .game-stats {
        gap: 20px;
    }

    .game-controls {
        flex-wrap: wrap;
    }

    .score-display {
        flex-direction: column;
        gap: 10px;
    }

    .game-title {
        font-size: 2rem;
    }

    .menu-container {
        padding: 30px 20px;
    }
    
    .bottle {
        max-width: 60px;
    }
}

@media (max-width: 480px) {
    .game-board {
        width: 99%;
    }
    
    .bottle {
        max-width: 45px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .btn {
        padding: 12px 20px;
        font-size: 1rem;
    }
}
