/* 카드 뒤집기 게임 스타일 */
.memory-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px 80px;
    min-height: 100vh;
    padding-bottom: calc(50px + 20px); /* 스크롤버튼 + 띠배너1번 + 띠배너여백 + 고정배너 + 여백 */
}

.memory-header {
    text-align: center;
    margin-bottom: 40px;
}

.memory-title {
    font-size: 42px;
    font-weight: 700;
    color: #2D2D2D;
    margin-bottom: 12px;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.8), 0 0 10px rgba(255, 182, 193, 0.5);
}

.memory-subtitle {
    font-size: 18px;
    color: #5A5A5A;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* 게임 설정 */
.game-setup {
    animation: fadeInUp 0.6s ease;
}

.setup-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 40px 30px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.setup-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 30px;
}

.difficulty-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.difficulty-btn {
    flex: 1;
    min-width: 120px;
    padding: 24px 20px;
    background: #fafafa;
    border: 2px solid #f0f0f0;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.difficulty-btn:hover {
    transform: translateY(-4px);
    border-color: var(--primary-pink);
    background: var(--gradient-2);
    box-shadow: var(--shadow-md);
}

.difficulty-btn.selected {
    border-color: var(--primary-pink);
    background: var(--gradient-1);
    color: white;
    box-shadow: var(--shadow-md);
}

.difficulty-size {
    font-size: 28px;
    font-weight: 700;
    color: inherit;
}

.difficulty-label {
    font-size: 14px;
    font-weight: 500;
    color: inherit;
}

/* 게임 영역 */
.game-area {
    animation: fadeInUp 0.6s ease;
}

.game-area.hidden {
    display: none;
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px 30px;
    box-shadow: var(--shadow-md);
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.info-label {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
}

.info-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
}

/* 카드 그리드 */
.cards-grid {
    display: grid;
    gap: 12px;
    justify-content: center;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.cards-grid.size-2x2 {
    grid-template-columns: repeat(2, 1fr);
    max-width: 400px;
    margin: 0 auto;
}

.cards-grid.size-4x4 {
    grid-template-columns: repeat(4, 1fr);
    max-width: 600px;
    margin: 0 auto;
}

.cards-grid.size-6x6 {
    grid-template-columns: repeat(6, 1fr);
    max-width: 700px;
    margin: 0 auto;
}

.cards-grid.size-8x8 {
    grid-template-columns: repeat(8, 1fr);
    max-width: 800px;
    margin: 0 auto;
}

.memory-card {
    aspect-ratio: 1;
    background: var(--gradient-1);
    border-radius: var(--radius-md);
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
    border: 2px solid transparent;
}

.memory-card.flipped {
    transform: rotateY(180deg);
}

.memory-card.matched {
    opacity: 1;
    cursor: default;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3);
}

.memory-card.matched.flipped {
    transform: rotateY(180deg);
}

.memory-card.disabled {
    pointer-events: none;
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.card-front {
    background: var(--gradient-1);
    font-size: 28px;
}

.card-back {
    background: white;
    transform: rotateY(180deg);
    font-size: 48px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

/* 난이도별 카드 크기 조정 */
.size-2x2 .card-back {
    font-size: 64px;
}

.size-4x4 .card-back {
    font-size: 48px;
}

.size-6x6 .card-back {
    font-size: 36px;
}

.size-8x8 .card-back {
    font-size: 28px;
}

/* 게임 완료 */
.game-complete {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.game-complete.hidden {
    display: none;
}

.complete-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: 40px 30px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
}

.complete-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: bounce 0.6s ease;
}

.complete-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 20px;
}

.complete-time,
.complete-moves {
    font-size: 18px;
    color: var(--text-medium);
    margin-bottom: 12px;
}

.complete-time span,
.complete-moves span {
    font-weight: 700;
    color: var(--text-dark);
}

.play-again-btn {
    margin-top: 24px;
    padding: 14px 32px;
    background: var(--gradient-1);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    font-family: 'Pretendard', sans-serif;
}

.play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* 랭킹 섹션 */
.ranking-section {
    margin-top: 40px;
    animation: fadeInUp 0.6s ease 0.2s both;
}

.ranking-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 30px;
    box-shadow: var(--shadow-lg);
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.ranking-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
}

.reset-ranking-btn {
    padding: 8px 16px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-sm);
    color: var(--text-medium);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Pretendard', sans-serif;
}

.reset-ranking-btn:hover {
    background: #ffebee;
    border-color: #f44336;
    color: #f44336;
}

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

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #fafafa;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
}

.ranking-item:hover {
    background: #f5f5f5;
    transform: translateX(4px);
}

.ranking-item.top {
    background: var(--gradient-2);
    border-left: 4px solid var(--primary-pink);
}

.ranking-rank {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    min-width: 40px;
}

.ranking-info {
    flex: 1;
    margin-left: 16px;
}

.ranking-size {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.ranking-time {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
}

.ranking-moves {
    font-size: 14px;
    color: var(--text-medium);
    margin-left: 12px;
}

.no-ranking {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
    font-size: 16px;
}

/* 애니메이션 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* 반응형 */
@media (max-width: 768px) {
    .memory-container {
        padding: 20px 16px 80px;
        padding-bottom: calc(50px + 20px); /* 스크롤버튼 + 띠배너1번 + 띠배너여백 + 고정배너 + 여백 */
    }
    
    .memory-title {
        font-size: 32px;
    }
    
    .difficulty-options {
        gap: 12px;
    }
    
    .difficulty-btn {
        min-width: 100px;
        padding: 20px 16px;
    }
    
    .difficulty-size {
        font-size: 24px;
    }
    
    .game-info {
        gap: 20px;
        padding: 16px 20px;
    }
    
    .info-value {
        font-size: 20px;
    }
    
    .cards-grid {
        gap: 6px;
        padding: 12px;
    }
    
    .size-2x2 .card-back {
        font-size: 48px;
    }
    
    .size-4x4 .card-back {
        font-size: 36px;
    }
    
    .size-6x6 .card-back {
        font-size: 24px;
    }
    
    .size-8x8 .card-back {
        font-size: 18px;
    }
    
    .card-front {
        font-size: 20px;
    }
    
    .ranking-card {
        padding: 20px;
    }
}
